how to print reverse of a number in c++-
you have given a number for eg. 123456789 and have to print 987654321.
c++ code to print reverse a number=
#include<iostream> | |
using namespace std; | |
int main(){ | |
int n; | |
cin>>n; | |
int x; | |
for(x=0;n>0;n = n/10){ | |
x = x*10 + n%10; | |
} | |
cout<<x<<endl; } | |