C Program to print reverse of a number.
#include<stdio.h>
int main() {
int num, rev=0, rem;
printf("Enter a number : ");
scanf("%d",&num);
while (num>0){
rem = num%10;
rev = rev*10+rem;
num /= 10;
}
printf("The reverse of the number is : %d",rev);
return 0;
}
The output should be like this...
Enter a number : 12345
The reverse of the number is : 54321
No comments:
Post a Comment