Write a C Program to Reverse a Number using while loop
In this post we will discuss Program to Reverse a Number using while loop. In this program, we will supply an integer value, in the output we will get the reverse of the entered number.
Suppose you enter a number as 3246 then the output of the program will be 6423
Suppose you enter a number as 3246 then the output of the program will be 6423
main()
{
int n, s;
printf("Enter Number ");
scanf("%d",&n);
s = 0;
while(n > 0)
{
s = s*10;
s = s + (n%10);
n = n / 10;
}
printf("Reverse number is: %d",s);
}
Output
Enter Number 234
Reverse number is 432