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:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s