SlideShare una empresa de Scribd logo
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]

Más contenido relacionado

La actualidad más candente

Programación modular estructurada.ppt
Programación modular estructurada.pptProgramación modular estructurada.ppt
Programación modular estructurada.ppt
Leydi Hernandez
 
Apresentação Sistemas Distribuídos - Conceito
Apresentação Sistemas Distribuídos - ConceitoApresentação Sistemas Distribuídos - Conceito
Apresentação Sistemas Distribuídos - Conceito
Thiago Marinho
 
Asignación, Salida y Entrada
Asignación, Salida y EntradaAsignación, Salida y Entrada
Asignación, Salida y Entrada
Carlos Pes
 
Arquitetura de Computadores: Processos e Threads
Arquitetura de Computadores: Processos e ThreadsArquitetura de Computadores: Processos e Threads
Arquitetura de Computadores: Processos e Threads
Evandro Júnior
 
Comandos básicos ms dos
Comandos básicos ms dosComandos básicos ms dos
Comandos básicos ms dos
briant95
 
3.1 politica y_filosofia
3.1 politica y_filosofia3.1 politica y_filosofia
3.1 politica y_filosofia
beymarlopez
 
Aula 1 estruturas de controlo (final)
Aula 1   estruturas de controlo (final)Aula 1   estruturas de controlo (final)
Aula 1 estruturas de controlo (final)
mestradopeci2012
 
Algoritmos e Técnicas de Programação - Aula 01
Algoritmos e Técnicas de Programação - Aula 01Algoritmos e Técnicas de Programação - Aula 01
Algoritmos e Técnicas de Programação - Aula 01
thomasdacosta
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Darwin Durand
 
Selección de un método de evaluación
Selección de un método de evaluaciónSelección de un método de evaluación
Selección de un método de evaluación
Bettys Arenas de Ruiz
 
Aula 6 - Estruturas de seleção encadeada - parte 1
Aula 6 - Estruturas de seleção encadeada - parte 1Aula 6 - Estruturas de seleção encadeada - parte 1
Aula 6 - Estruturas de seleção encadeada - parte 1
Pacc UAB
 
Estructura y funcionamiento del procesador
Estructura y funcionamiento del procesadorEstructura y funcionamiento del procesador
Estructura y funcionamiento del procesador
Jose Diaz Silva
 
Estrutura de dados
Estrutura de dadosEstrutura de dados
Estrutura de dados
Daniel Fernandes Costa
 
2009 1 - sistemas operacionais - aula 3 - processos
2009 1 - sistemas operacionais - aula 3 - processos2009 1 - sistemas operacionais - aula 3 - processos
2009 1 - sistemas operacionais - aula 3 - processos
Computação Depressão
 
Protótipo de Simulador de Elevadores
Protótipo de Simulador de ElevadoresProtótipo de Simulador de Elevadores
Protótipo de Simulador de Elevadores
Mauricio Volkweis Astiazara
 

La actualidad más candente (15)

Programación modular estructurada.ppt
Programación modular estructurada.pptProgramación modular estructurada.ppt
Programación modular estructurada.ppt
 
Apresentação Sistemas Distribuídos - Conceito
Apresentação Sistemas Distribuídos - ConceitoApresentação Sistemas Distribuídos - Conceito
Apresentação Sistemas Distribuídos - Conceito
 
Asignación, Salida y Entrada
Asignación, Salida y EntradaAsignación, Salida y Entrada
Asignación, Salida y Entrada
 
Arquitetura de Computadores: Processos e Threads
Arquitetura de Computadores: Processos e ThreadsArquitetura de Computadores: Processos e Threads
Arquitetura de Computadores: Processos e Threads
 
Comandos básicos ms dos
Comandos básicos ms dosComandos básicos ms dos
Comandos básicos ms dos
 
3.1 politica y_filosofia
3.1 politica y_filosofia3.1 politica y_filosofia
3.1 politica y_filosofia
 
Aula 1 estruturas de controlo (final)
Aula 1   estruturas de controlo (final)Aula 1   estruturas de controlo (final)
Aula 1 estruturas de controlo (final)
 
Algoritmos e Técnicas de Programação - Aula 01
Algoritmos e Técnicas de Programação - Aula 01Algoritmos e Técnicas de Programação - Aula 01
Algoritmos e Técnicas de Programação - Aula 01
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
Selección de un método de evaluación
Selección de un método de evaluaciónSelección de un método de evaluación
Selección de un método de evaluación
 
Aula 6 - Estruturas de seleção encadeada - parte 1
Aula 6 - Estruturas de seleção encadeada - parte 1Aula 6 - Estruturas de seleção encadeada - parte 1
Aula 6 - Estruturas de seleção encadeada - parte 1
 
Estructura y funcionamiento del procesador
Estructura y funcionamiento del procesadorEstructura y funcionamiento del procesador
Estructura y funcionamiento del procesador
 
Estrutura de dados
Estrutura de dadosEstrutura de dados
Estrutura de dados
 
2009 1 - sistemas operacionais - aula 3 - processos
2009 1 - sistemas operacionais - aula 3 - processos2009 1 - sistemas operacionais - aula 3 - processos
2009 1 - sistemas operacionais - aula 3 - processos
 
Protótipo de Simulador de Elevadores
Protótipo de Simulador de ElevadoresProtótipo de Simulador de Elevadores
Protótipo de Simulador de Elevadores
 

Similar a while y do while

Pr109 while
Pr109 whilePr109 while
Pr109 while
yonatan novoa
 
Estructura repetitiva
Estructura repetitivaEstructura repetitiva
Estructura repetitiva
Alcira Ordóñez Rey
 
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
painni
 
Clase lenguaje c xxxxxx
Clase lenguaje c xxxxxxClase lenguaje c xxxxxx
Clase lenguaje c xxxxxx
Mar15marian
 
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 xxxxxx
Mar15marian
 
Guia4
Guia4Guia4
Guia4
henser
 
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
jcbp_peru
 
Estructuras De RepeticióN
Estructuras De RepeticióNEstructuras De RepeticióN
Estructuras De RepeticióN
Regina Flores
 
Estructuras De RepeticióN
Estructuras De RepeticióNEstructuras De RepeticióN
Estructuras De RepeticióN
Regina Flores
 
Instruccion while bm
Instruccion while bmInstruccion while bm
Instruccion while bm
luisenrique10325143564684643
 
estructuras de repeticion
estructuras de repeticionestructuras de repeticion
estructuras de repeticion
adark
 
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
 
3 condicionales y ciclos
3 condicionales y ciclos3 condicionales y ciclos
3 condicionales y ciclos
Claribel Eusebio Nolasco
 
Clase 8
Clase 8Clase 8
Clase 8
esvin Rey
 
Sentencia de control
Sentencia de controlSentencia de control
Sentencia de control
Stalyn Cruz
 
Introduccion a C++
Introduccion a C++Introduccion a C++
Introduccion a C++
LenHugo
 
03 iteracion
03 iteracion03 iteracion
03 iteracion
Edson Vasquez
 
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
 
pptx.s3.pdf
pptx.s3.pdfpptx.s3.pdf
pptx.s3.pdf
eduardobejar21
 

Similar a while y do while (20)

Pr109 while
Pr109 whilePr109 while
Pr109 while
 
Estructura repetitiva
Estructura repetitivaEstructura repetitiva
Estructura repetitiva
 
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 xxxxxx
Clase lenguaje c xxxxxxClase lenguaje c xxxxxx
Clase lenguaje c xxxxxx
 
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
 
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
 

Más de Gustavo Medina

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

Más 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
 

while y do while

  • 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.