Reverse of a three digit number

5.Write a program to reverse a three digit number?
#include
#include
void main()
{
int a,r1,r2,b,c,rev;
clrscr();
printf("enter the no.");
scanf("%d",&a);
r1=a%10;
b=a/10;
r2=b%10;
c=b/10;
rev=(r1*100)+(r2*10)+c;
printf("reverse %d",rev);
getch();
}


Algorithum
1.start
2.read a
3.calculate
r1=a%10
b=a/10
r2=b/10
c=b/10
rev=(r1*100)+(r2*10)+c
4.print rev
5.stop


Result
The program was sucessfully executed and desired output is obtained

Output
enter the no.
123
reverse is 321

0 comments:

Post a Comment