Reverse Number

Reverse of 12345 is 54321. should not use string.
#include < stdio.h >
int main()
{
int n,a,b;
printf("ENTER THE Number");
scanf("%d",&n);
b=0;
while(n!=0)
{
a=n%10;
b=(b*10)+a;
n=n/10;
}
printf("REVERSED NUMBER:");
printf("%d",b);
}


Output:


ENTER THE NUMBER:
54321

REVERSED NUMBER:
12345

Related Posts