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>.8<br />

El siguiente programa, PARES.CPP, inicializa los elementos de un arreglo llamado arreglo de diez<br />

elementos a los enteros 2, 4, 6, ... , 20, e imprime el arreglo en formato de tabla. Estos números se generan<br />

multiplicando por 2 cada valor consecutivo del contador del ciclo y sumándole 2.<br />

/* Este programa: PARES.CPP inicializa un arreglo con los enteros pares comprendidos<br />

entre 2 y 20 inclusive.<br />

*/<br />

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

#include //Para setw()<br />

void main(void)<br />

{<br />

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

const int TAMANO_ARREGLO = 10;<br />

int j, arreglo[TAMANO_ARREGLO];<br />

for(j = 0; j < TAMANO_ARREGLO;j++) //Inicializa arreglo<br />

arreglo[j] = 2 + 2 * j;<br />

cout

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

Saved successfully!

Ooh no, something went wrong!