c do while
do {
// code
} while(/* condition */);
while loop in c
//While loop, for the largest of two numbers.
#include <stdio.h>
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);
}
WHILE loop in c
while( a < 20 ) {
printf("value of a: %d\n", a);
a++;
}
do while loop in c
//This program stops when a number greater than 10 is printed and prints that, value greater than 10
#include <stdio.h>
main()
{
int a;
do
{
printf("\nEnter your value: ");
scanf("%d", &a);
} while (a<10);
printf("Value greater than 10");
}
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;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us