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!
8 Respuestas
0
plz write in English
0
What should this program?
0
The program contains errors, it will not work.
0
reverse number
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;
}
0
78 87
12 21
07 70
0
it's nice code but only for 2 numbers ! 😘
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;
}