Write a program to reverse a number.
#include <stdio.h>
int main()
{
long num, revers;
int digit;
revers = 0;
printf("Enter number: ");
scanf("%ld", &num);
while (num > 0)
{
digit = num % 10;
num = num / 10;
revers = revers * 10;
revers = revers + digit;
}
printf("\n\nRevers: %ld\n", revers);
return 0;
}
Comments
Leave a comment