Write a C++ program that inputs a five digit number as input and reverse the number.

 #include<iostream>

using namespace std;

int main()

{

int n, a, b, c, d;

cout<<"Enter 5-digit number: ";

cin>>n;

a = n/1000;

n = n%1000;

b = n/1000;

n = n%1000;

c = n/100;

n = n%100;

d = n/10;

n = n%10;

cout<<"Number is reverse order is "<<n<<d<<c<<b<<a;

}

OUTPUT

Enter 5-digit number: 16345

Number is reverse order is 54316

1 comment: