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;
}
No comments:
Post a Comment