Pages

Saturday, December 17, 2011

Program to reverse input number

This program reverse the input number.

If a five-digit number is input through the keyboard,write a program to reverse the number

#include<stdio.h>
#include<conio.h>
void main()
{
long num,r;
long sum=0;
clrscr();

printf("Enter number : ");
scanf("%ld",&num);


while(num!=0)
{
r=num%10;
num=num/10;

sum=(sum*10)+r;

}
printf("%ld",sum);

getch();
}

No comments: