<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE type=text/css>DIV {
        MARGIN: 0px
}
</STYLE>

<META content="MSHTML 6.00.2900.3020" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hola Santiago,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>evidentemente los dos bucles hacen lo mismo. Lo que 
se hace con while se puede hacer for y do-while. El do-while tiene la salvedad 
que al menos siempre se ejecuta una vez por evalua la condición después de hacer 
lo que haya en el cuerpo del do, en cambio while evalua primero la 
condición y si es falsa no hace nada.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Fijate que para crear un bucle infinito puedes 
hacer for(;;) o también while(1). Como puedes ver en for no hay que especificar 
todos los parámetros por lo que se puede emular un bucle while con for sin 
problemas.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Usar uno o otro es cuestión de gustos, pero cuando 
se trabaja con datos que siguen una sucesión de paso conocido (índices de un 
array, obtener el valor de una función cada segundo, etc) se suele usar for. En 
cambio cuando se tiene que ejecutar un grupo de funciones mientrás 
se cumpla una determinada condición se usar while o do-while (para que se 
realice al menos una vez). Piensa que esa condición no tiene porque ser 
modificada obligatoriamente dentro del bucle, puede haber más de un hilo en una 
aplicación y que otro hilo modifique su valor.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Un saludo,</FONT></DIV>
<DIV><FONT face=Arial size=2>Juan Antonio.</FONT></DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=melasudaquique@yahoo.es 
  href="mailto:melasudaquique@yahoo.es">Santiago García</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A 
  title=cconclase@listas.conclase.net 
  href="mailto:cconclase@listas.conclase.net">C++ Preguntas</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, January 25, 2007 4:53 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [C con Clase] Bucles</DIV>
  <DIV><BR></DIV>
  <DIV 
  style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
  <DIV>Hola, ¿alguien me puede explicar la diferencia entre los tres tipos de 
  bucles. Porque es igual esto:</DIV>
  <DIV> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>#include<iostream></FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" color=#0000ff>using namespace 
  std;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff></FONT> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" color=#0000ff>int 
  main()<BR>{</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    int x;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff></FONT> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    for(x = 0; x < 10; x ++)</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    {</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>        cout << 
  x;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    }</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff></FONT> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    cin.get();</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    return 0;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" color=#0000ff>}</FONT></DIV>
  <DIV> </DIV>
  <DIV>Que esto:</DIV>
  <DIV> </DIV>
  <DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>#include<iostream></FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" color=#0000ff>using namespace 
  std;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff></FONT> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" color=#0000ff>int 
  main()<BR>{</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    int x = 0;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff></FONT> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    while(x < 10)</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    {</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>        cout << 
  x;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>        x 
  ++;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    }</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff></FONT> </DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    cin.get();</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" 
  color=#0000ff>    return 0;</FONT></DIV>
  <DIV><FONT face="tahoma, new york, times, serif" color=#0000ff>}</FONT></DIV>
  <DIV><FONT face=Tahoma color=#0000ff></FONT> </DIV>
  <DIV><FONT face="times new roman, new york, times, serif">Un saludo y gracias, 
  Alejandro y Santiago.</FONT></DIV></DIV></DIV><BR>
  <HR SIZE=1>
  <BR><FONT face=Verdana size=-2>LLama Gratis a cualquier PC del 
  Mundo.<BR>Llamadas a fijos y móviles desde 1 céntimo por minuto.<BR><A 
  href="http://us.rd.yahoo.com/mail/es/tagline/messenger/*http://es.voiceyahoo.com/">http://es.voice.yahoo.com</A></FONT>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>Lista de correo 
  Cconclase 
  Cconclase@listas.conclase.net<BR>http://listas.conclase.net/mailman/listinfo/cconclase_listas.conclase.net<BR>Bajas: 
  http://listas.conclase.net/index.php?gid=2&mnu=FAQ</BLOCKQUOTE></BODY></HTML>