C Program to Reverse a Number
C Program to Reverse a
Number
#include
<stdio.h>
int main()
{
int n,
reversedNumber = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while(n !=
0)
{
remainder = n%10;
reversedNumber = reversedNumber*10 + remainder;
n /=
10;
}
printf("Reversed Number = %d", reversedNumber);
return 0;
}
Output:
Enter an integer: 2345
Reversed Number = 5432
Please write comments if you find anything
incorrect, or you want to share more information about the topic discussed
above.