Sunday, 13 November 2011

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

/*Reverse a Number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int number,reverse_number;
clrscr();
printf("Enter the Number you want to reverse:");
scanf("%d",&number);
/*we use while loop and '%' to seprate a number*/
printf("Reverse number is:");
while(number>0)
{
reverse_number=number%10;
number=number/10;//update number
printf("%d",reverse_number);
}
getch();
}

No comments:

Post a Comment