![All while loops programs with output in c language All while loops programs with output in c language](https://blogger.googleusercontent.com/img/a/AVvXsEgJ0CepgL-2cBrgrLwrFsmTKOieiYmpBsmE07koLu4rWu8j-adpfL4uMx1nGulevAYp6LTwXimggWotJP4AymeE2GB5QzsmUN0QuOxsMVA6IcZMD3ALHI_9VR_9XUc16AKhwdF48hbXTQldWfov5SM9BWHnxYz12NB1sQ7snItUg_06gfo4LSxJ8cBWRg=w640-h360)
All while loops programs with output in c language
All while loops programs with output in c language
While Loop: The while loop is a control flow statement that allows an operation to be performed repeatedly as long as a condition is true.
The while loop will execute the statements in the body of the loop as long as the given condition evaluates to true. The first time that this conditional expression is evaluated, it will be false and so no statements within the body of the loop will be executed.
The next time that this conditional expression is evaluated, it will again be false and so no statements within the loop's body will execute for a second time. If this conditional expression evaluates to true, then it will continue evaluating to true until something causes it to evaluate to false.
How to print 1 to 10 table using while loop?
#include<stdio.h> int main() { int i=1; while(i<=10) { printf("%d\n",i); i++; } } *****OUTPUT***** 1 2 3 4 5 6 7 8 9 10 |
How to print digit value in reverse order?
#include<stdio.h> int main() { int no,b; printf("Enter any Number:"); scanf("%d",&no); printf("Reverse is given below\n"); while(no!=0) { b=no%10; printf("%d",b); no=no/10; } } *****OUTPUT***** Enter any Number:12345679 The reverse is given below 97654321 |
How to check number is palindrome or not palindrome?
#include<stdio.h> int main() { int no,b,rev=0,cpy; printf("Enter any Number:"); scanf("%d",&no); cpy=no; while(no!=0) { b=no%10; rev=rev*10+b; no=no/10; } if(cpy==rev) printf("Palindrome"); else printf("Not Palindrome"); } *****OUTPUT***** Enter any Number:8 Palindrome |
How to find sum of digit of integer value using while loop?
#include<stdio.h> int main() { int no,b,sum=0; printf("Enter any Number:"); scanf("%d",&no); while(no!=0) { b=no%10; sum=sum+b; no=no/10; } printf("Total sum of digits:%d",sum); } *****OUTPUT***** Enter any Number:790 The total sum of digits:16 |
How to find multiplication of integer value using while loop?
#include<stdio.h> int main() { int no,b,m=1; printf("Enter any Number:"); scanf("%d",&no); while(no!=0) { b=no%10; m=m*b; no=no/10; } printf("Total multiply of digits:%d",m); } *****OUTPUT***** Enter any Number:345 Total multiply of digits:60 |
How to print first value and last value using while loop?
#include<stdio.h> int main() { int no,b,f; printf("Enter any Number:"); scanf("%d",&no); f=no%10; while(no!=0) { b=no%10; no=no/10; } printf("First digit:%d and last digit:%d",b,f); } *****OUTPUT***** Enter any Number:5463 First digit:5 and last digit:3 |