Wednesday, 26 October 2016

C++ program of reverse a number

In this C++ program we will learn how to reverse the sequence of entered numbers

//Code starts
#include<iostream>
#include<conio.h>
using namespace std; 
int main()
{
int number, reverse = 0; 
cout<<"Input a Number to Reverse and press Enter: "; 
cin>> number; // Taking Input Number in variable number 
while( number> 0 ) 
reverse = reverse * 10; 
reverse = reverse + number%10;
number = number/10; 
}
 cout<<"New Reversed Number is: "<<reverse;
getch();
}
//Code Ends

Output:


Share: