SlideShare uma empresa Scribd logo
1 de 41
Tema 4 Estructuras de Control Iterativas
Estructuras iterativas ,[object Object],[object Object],[object Object]
Iteraciones en c ,[object Object],[object Object],[object Object]
Sentencia   while ,[object Object],[object Object],[object Object],[object Object],¿condición? V F Bloque de instrucciones
S emántica de   while ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Ejemplo
Ejemplo
Iteraciones en c ,[object Object],[object Object],[object Object]
Sentencia   do-while ,[object Object],[object Object],[object Object],[object Object],¿condición? V F Bloque de instrucciones
S emántica de   do- while ,[object Object],[object Object],[object Object],[object Object],[object Object]
Ejemplo ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ejemplo
Diseño  de la iteración ,[object Object],[object Object],[object Object],[object Object]
Diseño  de la iteración ,[object Object],[object Object],[object Object],[object Object],[object Object]
Diseño  de la iteración ,[object Object],[object Object],[object Object]
Ejemplo resuelto ,[object Object],[object Object]
Control de la iteración ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Proceso de la iteración ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Algoritmo Inicialización Control Proceso INICIO LEER ( a ) b =1 b <=10 ESCRIBIR  a * b Saltar de línea b = b +1 V F FIN
Código ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Comprobación (trazas) 20 5 4 16 4 4 24 6 4 8 2 4 12 3 4 4 1 4 .. .. .. 10 b 40 4 c a
Ejemplo/ ejercicio 1 ,[object Object],[object Object],[object Object]
Algoritmo (con do-while) F Calcular  num  en pesetas Escribir resultado en pesetas ¿Qué deseas (P/E)?    opc ¿ opc  == ‘P’? V ¿Qué número?   num Calcular  num  en euros Escribir resultado en euros ¿Más números (S/N)?   resp ¿ resp  == ‘S’? V F FIN
Algoritmo (con  while ) resp=‘S’ Calcular  num  en pesetas Escribir resultado en pesetas ¿Más números (S/N)?   resp F ¿ opc  == ‘P’? V Calcular  num  en euros Escribir resultado en euros ¿Qué deseas (P/E)?    opc ¿Qué número?   num ¿ resp  == ‘S’? V F FIN
Ejemplo/ ejercicio 2 ,[object Object],Leer  Numero ¿Potencia< Numero ? Escribir Potencia V F Potencia = 1 Potencia = Potencia * 2
Código (con  while ) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ejemplo/ ejercicio 3 ,[object Object],Leer  car  (un carácter) ¿ car  !=‘.’? Escribir num V F num = 1 num = num +1 Leer  car
Código (con  while ) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Código (con  do-while ) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ejercicios ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Iteraciones en c ,[object Object],[object Object],[object Object]
Sentencia   for ,[object Object],[object Object],[object Object],[object Object],¿condición? V F Bloque de instrucciones Inicialización Actualización
Semántica  de   for ,[object Object],[object Object],[object Object],[object Object],[object Object]
Equivalencia  for  -  while inicialización; while ( condición ) { bloque_instrucciones; actualización: } for ( inicialización ;  condición;   actualización ) { bloque_instrucciones; }
Ejemplo ,[object Object],scanf (“%d”, &n) i=1; while (i<=n) { printf(“ %d”, 2*i); i= i+1; } scanf (“%d”, &n) for (i=1;  i<=n;  i= i+1) { printf(“ %d”, 2*i); }
Estructuras  iterativas ,[object Object],[object Object],[object Object],[object Object]
Ejercicios
Ejercicio  factorial ,[object Object],[object Object]
while Leer el número     num ¿ num  == 0? fact = 1 Escribir resultado ¿ num  <0? No se puede Calcular  num ! fact = 1 i = 1 ¿ i  <=  num ? fact = fact * i i = i + 1 Escribir fact V V V F F F
for for (i=1;i<=num;i=i+1) {fact=fact*i;} Leer el número     num ¿ num  == 0? fact = 1 Escribir resultado ¿ num  <0? No se puede calcular  num ! fact = 1; Repetir desde que i vale 1 hasta que i valga  num , i=i+1; fact = fact * i; Escribir fact SI SI NO NO
Más ejercicios ,[object Object],[object Object],[object Object],[object Object]

Mais conteúdo relacionado

Semelhante a Estructuras iterativas

Introducción A Las Estructuras De Seleccion En C
Introducción A Las Estructuras De Seleccion En CIntroducción A Las Estructuras De Seleccion En C
Introducción A Las Estructuras De Seleccion En Cpainni
 
Clase lenguaje c
Clase lenguaje c Clase lenguaje c
Clase lenguaje c Mar15marian
 
Clase lenguaje c xxxxxx
Clase lenguaje c xxxxxxClase lenguaje c xxxxxx
Clase lenguaje c xxxxxxMar15marian
 
Clase lenguaje c xxxxxx
Clase lenguaje c xxxxxxClase lenguaje c xxxxxx
Clase lenguaje c xxxxxxMar15marian
 
Ucv 2015-1_fd_p_s1_estructuras repetitivas
 Ucv 2015-1_fd_p_s1_estructuras repetitivas Ucv 2015-1_fd_p_s1_estructuras repetitivas
Ucv 2015-1_fd_p_s1_estructuras repetitivasjcbp_peru
 
Estructuras De RepeticióN
Estructuras De RepeticióNEstructuras De RepeticióN
Estructuras De RepeticióNRegina Flores
 
Estructuras De RepeticióN
Estructuras De RepeticióNEstructuras De RepeticióN
Estructuras De RepeticióNRegina Flores
 
estructuras de repeticion
estructuras de repeticionestructuras de repeticion
estructuras de repeticionadark
 
ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++die_dex
 
Sentencia de control
Sentencia de controlSentencia de control
Sentencia de controlStalyn Cruz
 
Introduccion a C++
Introduccion a C++Introduccion a C++
Introduccion a C++LenHugo
 
Programación de nivel básico 3. c2. p2.
Programación de nivel básico 3. c2. p2.Programación de nivel básico 3. c2. p2.
Programación de nivel básico 3. c2. p2.DENIRAMIREZANDRADE
 
Ejercicios propuestos
Ejercicios propuestosEjercicios propuestos
Ejercicios propuestosjfranco_123
 

Semelhante a Estructuras iterativas (20)

Introducción A Las Estructuras De Seleccion En C
Introducción A Las Estructuras De Seleccion En CIntroducción A Las Estructuras De Seleccion En C
Introducción A Las Estructuras De Seleccion En C
 
Clase lenguaje c
Clase lenguaje c Clase lenguaje c
Clase lenguaje c
 
Clase lenguaje c xxxxxx
Clase lenguaje c xxxxxxClase lenguaje c xxxxxx
Clase lenguaje c xxxxxx
 
Clase lenguaje c xxxxxx
Clase lenguaje c xxxxxxClase lenguaje c xxxxxx
Clase lenguaje c xxxxxx
 
Guia4
Guia4Guia4
Guia4
 
Ucv 2015-1_fd_p_s1_estructuras repetitivas
 Ucv 2015-1_fd_p_s1_estructuras repetitivas Ucv 2015-1_fd_p_s1_estructuras repetitivas
Ucv 2015-1_fd_p_s1_estructuras repetitivas
 
Estructuras De RepeticióN
Estructuras De RepeticióNEstructuras De RepeticióN
Estructuras De RepeticióN
 
Estructuras De RepeticióN
Estructuras De RepeticióNEstructuras De RepeticióN
Estructuras De RepeticióN
 
Instruccion while bm
Instruccion while bmInstruccion while bm
Instruccion while bm
 
estructuras de repeticion
estructuras de repeticionestructuras de repeticion
estructuras de repeticion
 
ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++ESTRUCTURAS DE CONTROL: BUCLES EN C++
ESTRUCTURAS DE CONTROL: BUCLES EN C++
 
3 condicionales y ciclos
3 condicionales y ciclos3 condicionales y ciclos
3 condicionales y ciclos
 
Clase 8
Clase 8Clase 8
Clase 8
 
Sentencia de control
Sentencia de controlSentencia de control
Sentencia de control
 
Introduccion a C++
Introduccion a C++Introduccion a C++
Introduccion a C++
 
03 iteracion
03 iteracion03 iteracion
03 iteracion
 
Programación de nivel básico 3. c2. p2.
Programación de nivel básico 3. c2. p2.Programación de nivel básico 3. c2. p2.
Programación de nivel básico 3. c2. p2.
 
pptx.s3.pdf
pptx.s3.pdfpptx.s3.pdf
pptx.s3.pdf
 
Ejercicios propuestos
Ejercicios propuestosEjercicios propuestos
Ejercicios propuestos
 
Plataformas tecnologicas introduccion visual studio
Plataformas tecnologicas introduccion visual studioPlataformas tecnologicas introduccion visual studio
Plataformas tecnologicas introduccion visual studio
 

Mais de Gustavo Medina

Mais de Gustavo Medina (6)

Infografia
InfografiaInfografia
Infografia
 
El sorbo
El sorboEl sorbo
El sorbo
 
Consultorias el jardin. ultimo
Consultorias el jardin. ultimoConsultorias el jardin. ultimo
Consultorias el jardin. ultimo
 
Reciclaje
ReciclajeReciclaje
Reciclaje
 
Tema 4 iterativas
Tema 4   iterativasTema 4   iterativas
Tema 4 iterativas
 
Tema 4 iterativas
Tema 4   iterativasTema 4   iterativas
Tema 4 iterativas
 

Estructuras iterativas

  • 1. Tema 4 Estructuras de Control Iterativas
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 8.
  • 9.
  • 10.
  • 11.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Algoritmo Inicialización Control Proceso INICIO LEER ( a ) b =1 b <=10 ESCRIBIR a * b Saltar de línea b = b +1 V F FIN
  • 20.
  • 21. Comprobación (trazas) 20 5 4 16 4 4 24 6 4 8 2 4 12 3 4 4 1 4 .. .. .. 10 b 40 4 c a
  • 22.
  • 23. Algoritmo (con do-while) F Calcular num en pesetas Escribir resultado en pesetas ¿Qué deseas (P/E)?  opc ¿ opc == ‘P’? V ¿Qué número?  num Calcular num en euros Escribir resultado en euros ¿Más números (S/N)?  resp ¿ resp == ‘S’? V F FIN
  • 24. Algoritmo (con while ) resp=‘S’ Calcular num en pesetas Escribir resultado en pesetas ¿Más números (S/N)?  resp F ¿ opc == ‘P’? V Calcular num en euros Escribir resultado en euros ¿Qué deseas (P/E)?  opc ¿Qué número?  num ¿ resp == ‘S’? V F FIN
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. Equivalencia for - while inicialización; while ( condición ) { bloque_instrucciones; actualización: } for ( inicialización ; condición; actualización ) { bloque_instrucciones; }
  • 35.
  • 36.
  • 38.
  • 39. while Leer el número  num ¿ num == 0? fact = 1 Escribir resultado ¿ num <0? No se puede Calcular num ! fact = 1 i = 1 ¿ i <= num ? fact = fact * i i = i + 1 Escribir fact V V V F F F
  • 40. for for (i=1;i<=num;i=i+1) {fact=fact*i;} Leer el número  num ¿ num == 0? fact = 1 Escribir resultado ¿ num <0? No se puede calcular num ! fact = 1; Repetir desde que i vale 1 hasta que i valga num , i=i+1; fact = fact * i; Escribir fact SI SI NO NO
  • 41.