Task: Reverse Number Code C Plus Plus
The Source Code of C++ Program:Reverse Number Code C Plus Plus
// Write a C++ program to input a number // and display its Reverse Number // For example, if you Enter number=123 // Program will show Reverse number=321 // www.EasyCodeBook.com #include<iostream> using namespace std; int main() { long int num,n,rev; printf("Enter an Integer Number:"); cin>>num; rev=0; for(n=num;n!=0;n=n/10) rev=(10*rev)+n%10; cout<<"Actual Number: "<<num<<endl; cout<<"Reverse Number: "<<rev; return 0; }
The output of the C++ Program Reverse Number
Enter an Integer Number:1236 Actual Number: 1236 Reverse Number: 6321 Another Sample Run Output: Enter an Integer Number:675213 Actual Number: 675213 Reverse Number: 312576