do while code example
Example 1: do whie loop
do{
----
} while(condition);
Example 2: while vs do while
Main difference while loop executes while
condition is true. But do while executes
at least one time regardless.
Example 3: Iterate with Do While Loops Javascript
var myArray = [];
var i = 10;
do { // The do while loop will always run atleast once before checking the condtion. This will return false and break out of the loop.
myArray.push(i);
i++;
} while (i < 5)
console.log(i, myArray);
Example 4: do-while in c
#include <stdio.h>
int main()
{
int j=0;
do
{
printf("Value of variable j is: %d\n", j);
j++;
}while (j<=3);
return 0;
}
Example 5: c make loop
// Print numbers from 1 to 5
#include <stdio.h>
int main()
{
int i = 1;
while (i <= 5)
{
printf("%d\n", i);
++i;
}
return 0;
}
Example 6: while
while True:
print("A period of time.")
# "we chatted for a while"
print("Similar: time spell stretch stint")
print("at the same time; meanwhile.")
# "he starts to draw. talking for a while"
"""
CONJUCTION :D
"""