Program to reverse any number

14. Write a program to reverse any number?
#include
#include
void main()
{
int n,d r=0;
clrscr()
printf("enter the no");
scanf("%d",&n);
while(n>0)
{
d=n%10;
r=(r*10)+d;
n=n/10;
}
printf("reverse %d",r);
getch();
}


Algorithum
1.start
2.read the number n,d,r
3.calculate d=n%10
r=(r*10)+d
n=n/10
4.print r
5.stop


Result
The program is sucessfully executed and desired output is obtained

Output
enter 234
432

0 comments:

Post a Comment