06.05.2013 Views

CONTENIDO DE LA LECCIÓN 18

CONTENIDO DE LA LECCIÓN 18

CONTENIDO DE LA LECCIÓN 18

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MIGUEL Á. TOLEDO MARTÍNEZ<br />

Ejemplo <strong>18</strong>.10<br />

El siguiente programa, SUMAVALORES.CPP, suma los valores contenidos en el arreglo de enteros de<br />

doce elementos.<br />

/* El siguiente programa: SUMAVALORES.CPP, Calcula la suma de los elementos de un arreglo. */<br />

#include //Para cout y cin<br />

void main(void)<br />

{<br />

Ejemplo <strong>18</strong>.11<br />

const int TAMANO_ARREGLO = 12;<br />

int arreglo[TAMANO_ARREGLO] = {1, 3, 5, 4, 7, 2, 99, 16, 45, 67, 89, 45};<br />

int total = 0;<br />

for(int i = 0; i < TAMANO_ARREGLO; i++)<br />

total += arreglo[i];<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!