#include<iostream.h>
void main()
{
int n,n1,n2,n3,n4,n5;
cout<<" Enter the 5-digit number : ";
cin>>n;
if(n<0 || n>99999)
cout<<"!!! Invalid Number !!!"<<endl;
else
{
n5 = n % 10;// fifth digit
n = n / 10;
n4 = n % 10;// fourth digit
n = n / 10;
n3 = n % 10;// third digit
n = n / 10;
n2 = n % 10;// second digit
n1 = n /10;// first digit
cout<< n1 <<"\t"<<n2<<"\t"<<n3<<"\t"<<n4<<"\t"<<n5<<endl;
cout<<" The number in reverse order is : ";
cout<<n5<<n4<<n3<<n2<<n1<<endl;
}
}
Output:
Enter the 5-digit number : 91467
9 1 4 6 7
The number in reverse order is : 76419
Press any key to continue |