do while c code example
Example 1: boucle for c
int compteur;
for (compteur = 0 ; compteur < 10 ; compteur++)
{
printf("Salut les Zeros !\n");
}
Example 2: do whie loop
do{
----
} while(condition);
Example 3: c do while
do {
// code
} while(/* condition */);
Example 4: WHILE loop in c
while( a < 20 ) {
printf("value of a: %d\n", a);
a++;
}
Example 5: while loop in c
//While loop, for the largest of two numbers.
int main(){
int a, b;
printf("Enter Values a and b:\n");
scanf("%d %d", &a, &b);
while (a < b){
printf("%d is greater than %d\n", b, a);
printf("Enter Values a and b:\n");
scanf("%d %d", &a, &b);
}
printf("%d is greater than %d\n", a, b);
}
Example 6: do-while in c
int main()
{
int j=0;
do
{
printf("Value of variable j is: %d\n", j);
j++;
}while (j<=3);
return 0;
}