Wednesday, July 20, 2011

Program to find reverse of any digit no.

/*Serial No.47     [swami18.cpp]*/ 

/*It works good up to 9-digits.*/
#include<stdio.h>
#include<conio.h>
void main()
{
long int num,rem,rev=0,num1;
clrscr();
printf("Enter any digit number for reverse===>");
scanf("%ld",&num);
num1=num;
while(num1>0)
{
rem=num1%10;
num1/=10;
rev=rev*10+rem;
}
printf("Reverse of %ld is===>%ld",num,rev);
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...