Searching...

Reverse value of Entered Number

15:31

write a program that reverse the value of given number like 12345 and program should output 54321
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int num,rev=0;
cout << "Enter an Integer: ";
cin >>num;
/*cout << "Enter The value of N: ";
cin >>n_value;*/
for (int i=num;i!=0;i=i/10)
{
rev=10*rev+i%10;
}
cout << "Entered Number is : " << num <<endl;
cout << "Reverse is: " << rev <<endl;
return 0;
}

0 comments:

Post a Comment

Thanks For Your FeedBack....

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.