Tuesday, 2 December 2014

/*
Q.    Write a C++ program to reverse a number using do-while loop.
*/

#include<iostream>
using namespace std;

main()
{
    int i,j,n,rev=0;
    cout<<"\nEnter a number=";
    cin>>n;
   
    do
    {
        rev=rev*10+n%10;
        n=n/10;
    }while(n!=0);
    cout<<"\nThe reverse number="<<rev;
}

No comments:

Post a Comment