02.08.2013 Views

Tema 3 - OCW

Tema 3 - OCW

Tema 3 - OCW

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.

3.5 Estructuras de Control de Flujo<br />

3.5.1 Estructura de Control Iterativa<br />

condición<br />

Sí<br />

cuerpo<br />

No<br />

cuerpo<br />

condición<br />

Metodología y Tecnología de la Programación<br />

<strong>Tema</strong> 3. Elementos Básicos de la Programación Imperativa<br />

No Sí<br />

Figura 3.1 Estructura Iterativa Mientras Figura 3.2 Estructura Iterativa Repetir<br />

3.5 Estructuras de Control de Flujo<br />

Ejemplo 3.19 Factorial de un número entero (Numero) mediante la estructura iterativa Para<br />

Variables<br />

Numero, Resultado, I ∈ Entero<br />

Acciones<br />

Resultado ← 1<br />

Para I ← 2..Numero Hacer<br />

Resultado ← Resultado * I<br />

Fin Para<br />

Ejemplo 3.20 Factorial de un número entero (Numero) mediante la estructura iterativa Mientras<br />

Variables<br />

Numero, Resultado, I ∈ Entero<br />

Acciones<br />

Resultado ← 1<br />

I ← 2<br />

Mientras I ≤ Numero Hacer<br />

Resultado ← Resultado * I<br />

I ← I + 1<br />

Fin Mientras<br />

Metodología y Tecnología de la Programación<br />

<strong>Tema</strong> 3. Elementos Básicos de la Programación Imperativa<br />

47<br />

48<br />

24

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

Saved successfully!

Ooh no, something went wrong!