How To Print Reverse Of A Number In C

//Code

#include<stdio.h>
main()
{
int n,rev=0;
printf("Enter no to reverse\n");
scanf("%d",&n);
while(n>0)
{
rev=rev*10+n%10;
n=n/10;
}
printf("Reverse of no is=%d\n",rev);
}

No comments:

Post a Comment