Write a program that user inputs 3-digit number and its
output in reverse order.
#include <iostream.h>
#include <conio.h>
void main()
{
int digit,a,b,c,num,rev;
cout<<"Enter a three-digit number: ";
cin>>digit;
a=digit%10;
num=digit/10;
rev=a;
b=num%10;
num=num/10;
rev=(rev*10)+b;
c=num%10;
num=num/10;
rev=(rev*10)+c;
cout<<"\n Orignal number is:
"<<digit;
cout<<"\n Reverse number is:
"<<rev;
getch();
}
No comments:
Post a Comment