Reverse of Digits of a number is taken out in two steps. One, using the modulus operator (%) and taking remainder by dividing by 10 to get individual digits and then diving the number itself by 10 to reduce the least significant. It is similar to taking sum of digits.
Language : C
[sourcecode language='c']
//To reverse the digits of an entered number
#include
#include
void main()
{
int a,dig;
printf(“Enter a number : “);
scanf(“%d”, &a);
while(a!=0)
{
dig=a%10;
printf(“%d” ,dig);
a=a/10;
}
getch();
}
[/sourcecode]






