1 / 14

ESCUELA :

Metodología y Tecnología de la Programación I. Ciencias de la Computación. ESCUELA :. Ing. Danilo Jaramillo H. NOMBRES:. Octubre 2009 – Marzo 2010. FECHA:. Realizar el trabajo de forma personal Utilizar el EVA www.utpl.edu.ec Contestar los foros

aulani
Download Presentation

ESCUELA :

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Metodología y Tecnología de la Programación I Ciencias de la Computación ESCUELA: Ing. Danilo Jaramillo H. NOMBRES: Octubre 2009 – Marzo 2010 FECHA:

  2. Realizar el trabajo de forma personal • Utilizar el EVA www.utpl.edu.ec • Contestar los foros • Ejercicios, evaluaciones resueltas, problemas • Material adicional • Asesorías con el profesor • 07 – 2570 275 ext. 2637 (horario de tutoría) • Mail: djaramillo@utpl.edu.ec • Chat msn: djaramilloh@hotmail.com • Video llamadas skype: danilo.jaramillo.h

  3. Capítulo 4. Ciclos Repetitivos • Capítulo del texto • 5. La repetición do… while • 6. La repetición for.. • 7. La repetición while .. do

  4. Capítulo 4. Ciclos Repetitivos • Repetición de sentencias en base a una condición lógica. • Se los conoce también como bucles. • Se debe tener en cuenta: • cuantas veces se repite el bucle o el cuerpo del ciclo • determinar cuál será el cuerpo del mismo. • El cuerpo del bucle lo constituyen: • Sentencias de cualquier tipo • Se repiten de acuerdo a la condición del bucle.

  5. Capítulo 4. Ciclos Repetitivos • CONDICIÓN A LA SALIDA DO ………… WHILE (condición) • Se realiza 1 a n veces • Por lo menos una vez…

  6. Capítulo 4. Ciclos Repetitivos • CONDICIÓN A LA ENTRADA • WHILE (condición) …. sentencias ENDWHILE • FOR (cont = valorinic ; condición ;increm) …..sentencias ENDFOR • 0 a n veces • Puede no ejecutarse las sentencias

  7. Capítulo 4. Ciclos Repetitivos • ESTRUCTURAS REPETITIVAS ANIDADAS, bucles que están dentro de otro bucle. • Cuando se ANIDAN BUCLES, cuidado que el bucle inferior este contenido dentro del bucle exterior. (la utilización de variables) • TODOS LOS TIPOS DE BUCLES PUEDEN ANIDARSE, sea entre si o entre cada uno.

  8. ejercicio: Sumar numero Pares Menores a un Numero (número se lee por teclado) Si N = 17 2 + 4 + 6 + 8 + 12 + 14 + 16 = 62 Si N = 8 2 + 4 + 6 = 12

  9. ejercicios Algoritmo SumarParesMenoresN Clase Suma 1. Método Principal a. Declaraciones variables i, num, suma: ENTERO b. Imprimir “ingrese numero” c. Leer num d. Suma = 0 e. For (i=1; i < num; i++) 1. IF (i mod 2 = 0) THEN a. suma = suma + i 2. ENDIF f. ENDFOR g. Imprimir “la suma es “, suma h. Fin método principal Fin clase fin i < num i mod 2 = 0 (par)

  10. ejercicio // realizar la tabla de la suma Algoritmo tablademultiplicar Clase tabla 1. Método Principal a. Declaraciones variables n: entero b. leer n c. FOR (c=1; c <= n; c++) imprimir n, “ + ”,c, “ = ”, n +c ENDFOR Fin Método Principal Fin Clase fin Si n = 5 presentaría 5 + 1 = 6 5 + 2 = 7 5 + 3 = 8 5 + 4 = 9 5 + 5 = 10

  11. Ejemplo Si n = 5 presentaría 5 + 1 = 6 5 + 2 = 7 5 + 3 = 8 5 + 4 = 9 5 + 5 = 10 //realiza la tabla de la suma Algoritmo tablademultiplicar Clase tabla 1. Método Principal a. Declaraciones variables n, con: entero b. leer n c. c = 1 d. WHILE (c <= n) DO imprimir n, “ + ”,c, “ = ”, n+c c = c +1 ENDDO Fin Método Principal Fin Clase Fin

  12. Ejemplo: división por restas • 15 / 3 (DIVIDENDO / DIVISOR) • 15 – 3 = 12 1 • 12 – 3 = 9 1 • 9 – 3 = 6 1 • 6 – 3 = 3 1 • 3 – 3 = 0 1 • 0 TOTAL = 5 RESULTADO (LAS VECES QUE SE HIZO = 5) CONDICIÓN (DIVIDENDO SEA MAYOR DIVISOR)

  13. Ejemplo //realiza la tabla de multiplicar Algoritmo DIVISION Clase divisiones 1. Método Principal a. Declaraciones variables divi, divs, res: entero b. leer divi, divs c. res = 0 d. WHILE (divi >= divs) DO res = res +1 divi = divi - divs ENDDO e. imprimir “el resultado es”, res Fin Método Principal Fin Clase Fin

More Related