5. Reverse the given number.
#include <stdio.h>
#include <conio.h>
void main()
{
int num, rem, sum = 0, temp;
clrscr();
printf("Enter the number:");
scanf("%d", &num);
temp = num;
while (num != 0)
{
rem = num % 10;
sum = sum * 10 + rem;
num = num / 10;
}
printf("The Reverse of %d decimal digits is %d", temp, sum);
}
Output
Enter the number:5468
The Reverse of 5468 decimal digits is 8645