Este escrito fue probado por nuestros especialistas así aseguramos la veracidad de nuestro tutorial.
Ejemplo 1: ¿Cuál es la diferencia entre el bucle while y el bucle for?
//First Code WHILE loop
int x = 0;
while (x < 10)
//Do Something while x is less than 10
// if you don't want infinity loop increse x
x++;
//Second Code But Now Its FOR loop with the same int x with different different result
int x = 10
for (int i = 0; i < x; i++)
//Do Something while i is less than x
//in the while loop we executeing the code until all the conditions are true.
//in the for loop we are looping through the int that we created,
//in our loop the int is 'i', and every time we done execute the code in
//the loop we check if the condition that we gave in the loop in our is
//if 'i' < x and if it's false we are increasing 'i' and execute the code
//again until the condition is true.
Ejemplo 2: bucle while vs do while
Main difference while loop executes while
condition is true. But do while executes
at least one time regardless.
Reseñas y puntuaciones de la guía
Tienes la opción de añadir valor a nuestra información contribuyendo tu experiencia en las referencias.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)