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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

MIGUEL Á. TOLEDO MARTÍNEZ<br />

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

El siguiente programa, PROMEDIO1.CPP, calcula el promedio de los elementos de un arreglo. Los<br />

elementos del arreglo son preasignados.<br />

/* El siguiente programa: PROMEDIO1.CPP, calcula el valor promedio de un arreglo.<br />

Los elementos del arreglo están preasignados.<br />

*/<br />

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

const int TAMANO_ARREGLO = 10;<br />

void main(void)<br />

{<br />

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

double arreglo[TAMANO_ARREGLO] = { 12.2, 45.4, 67.2, 12.2, 34.6, 87.4,<br />

83.6, 12.3, 14.8, 55.5 };<br />

double suma = 0;<br />

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

{<br />

suma += arreglo[ix];<br />

cout

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

Saved successfully!

Ooh no, something went wrong!