+ 2

ahello everyone ...help required

how to invert 3 number in c++ like if we have a=123 in result we get 321 without using any loop or statement..

19th Feb 2019, 7:13 PM
Wasiq Abdullah
7 Respuestas
+ 3
*AsterisK* bro i need to make program .. in which when user input any integer value and in result we get reverse of entered value ...hows it be possible without using loops or if else statemets???
20th Feb 2019, 4:18 PM
Wasiq Abdullah
+ 9
There's no way you can do without if-else but you can do it recursively which don't need loop. If the number is limited to only 3 digits then you can hardcode it. #include <iostream> using namespace std; int reverse(int num, int sum) { if(num > 0) return reverse(num/10, ((sum * 10) + ((num % 10) * 10))); else return sum; } int main() { cout << reverse(3, 0) / 10 << endl; return 0; }
12th Apr 2019, 6:28 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 4
HonFu yes bro i mean without if else statement and loops..
20th Feb 2019, 4:15 PM
Wasiq Abdullah
+ 3
Without a statement? Sure about that?
19th Feb 2019, 8:23 PM
HonFu
HonFu - avatar
+ 2
can I use array for this Ch Wasiq
20th Feb 2019, 4:20 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
*AsterisK* yes bro why not ...if possible
20th Feb 2019, 6:39 PM
Wasiq Abdullah
+ 1
what do you mean????
19th Feb 2019, 8:28 PM
✳AsterisK✳
✳AsterisK✳ - avatar