What is while loop statement? Write an algorithm and a C program to input number and reverse it.
For information about while loop
C program to input number and reverse it
#include<stdio.h>
#include<conio.h>
void main()
{
int a, n, s=0;
printf("\n Enter a number");
scanf("%d", &a);
while(a>0)
{
n=a%10;
s=(s*10)+n;
a=a/10;
}
printf("\n Reverse number=%d", s);
getch();
}
Output


0 Comments
Please do not enter any spam link on comment box