0

what happen to this code! can anyone tell me about! why and how its work

int n, num, digit, rev =0; cout << "Enter a positive number: "; cin >> num; n = num; do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; means rev=0 so rev*10 should be 0! so why we write it and how its work becaues when i'm not write rev*10 and num=num/10 then its not work properly!

25th Feb 2017, 2:05 PM
Abrar Hussain
Abrar Hussain - avatar
8 ответов
0
plz write in English
25th Feb 2017, 4:38 PM
Abrar Hussain
Abrar Hussain - avatar
0
What should this program?
3rd Mar 2017, 1:40 PM
Юрий Исаев
Юрий Исаев - avatar
0
The program contains errors, it will not work.
3rd Mar 2017, 1:43 PM
Юрий Исаев
Юрий Исаев - avatar
0
reverse number
3rd Mar 2017, 4:16 PM
Abrar Hussain
Abrar Hussain - avatar
0
#include <iostream> using namespace std; int main() { int num,rev =0; cout << "Enter a positive number: "; cin >> num; rev = ((num % 10) * 10) + num /10; cout << num << ' ' << rev; return 0; }
3rd Mar 2017, 5:02 PM
Юрий Исаев
Юрий Исаев - avatar
0
78 87 12 21 07 70
3rd Mar 2017, 5:03 PM
Юрий Исаев
Юрий Исаев - avatar
0
it's nice code but only for 2 numbers ! 😘
4th Mar 2017, 10:01 AM
Abrar Hussain
Abrar Hussain - avatar
0
#include <iostream> using namespace std; int main() { int x,k=1; cin >> x; cout << x << ' '; do{ cout << x-(x/10)*10; x/=10; }while(x>1); return 0; }
4th Mar 2017, 7:39 PM
Юрий Исаев
Юрий Исаев - avatar