Here a simple C Program to Reverse a Number using loop is given,which takes a set of integer number from user and make it available to you in reverse order.There are several way to find the reverse of any number but here a simple c programming code is given below which takes any integer value and after successful execution it will give the reverse of original number.In this program a simple while loop is used for perform this task.
C Program to Reverse a Number using loop
#include <stdio.h>
int main()
{
int n, reverse=0, rem;
printf("Enter an integer: ");
scanf("%d", &n);
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n/=10;
}
printf("Reversed Number = %d",reverse);
return 0;
}
Output
Enter an integer: 2345 Reversed Number = 5432