+ 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..
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???
+ 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;
}
+ 4
HonFu yes bro i mean without if else statement and loops..
+ 3
Without a statement? Sure about that?
+ 2
can I use array for this Ch Wasiq
+ 2
*AsterisK* yes bro why not ...if possible
+ 1
what do you mean????