A program to find and print REVERSE of a given number
C Programming Language 035
The following code shows how to write a program to find and print REVERSE of a given number.
Program
#include <stdio.h>
void main()
{
int n, r = 0, rev = 0;
printf("Enter a number: ");
scanf("%d", &n);
while (n > 0)
{
r = n % 10;
rev = (rev*10) + r;
n = n / 10;
}
printf("Reverse = %d", rev);
printf("\n");
}
Result
Enter a number: 153
Reverse = 351
Last Updated on
Comments