Write a program to input a number and display the new number after reversing the digits of the original number. The program also displays the absolute difference between the original number and the reversed number.
Sample input : 123
Sample output : 321
Absolute difference : 198
Answers
Answered by
3
Answer:
<bits/stdc++.h>
using namespace std;
/* Iterative function to reverse digits of num*/
int reversDigits(int num)
{
int rev_num = 0;
while(num > 0)
{
rev_num = rev_num*10 + num%10;
num = num/10;
}
return rev_num;
}
/*Driver program to test reversDigits*/
int main()
{
int num = 4562;
cout << "Reverse of no. is "
<< reversDigits(num);
getchar();
return 0;
}
Answered by
0
Answer:
it answer will be as 0 because by solutions we can get it
Similar questions