Monday, 6 February 2017

Reversing a number

#include<iostream>
using namespace std;
void main()
{
 int number;
 int n_num=0;
 int digit = 0;
 cout << "Enter the number " << endl;
 cin >> number;

 while (number!=0) {
                         digit = number % 10;
                         n_num =digit + n_num * 10;
                         number = number/10;
 }


 cout << "The number after the reversing is " << n_num << endl;
 system("pause");
}

No comments:

Post a Comment