Is there a way to simplify this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there a way to simplify this code?

The code has to "reflex" given number. In example: 1234 to 4321. https://code.sololearn.com/cSzV7xo7XzFi/?ref=app

19th Sep 2019, 8:02 AM
Sweet Wafer
1 Answer
+ 4
#include <iostream> using namespace std; int reverse(int); int main() { int n; cin >> n; cout << reverse(n); return 0; } int reverse(int n) { int x=0; while (n > 0){ x=(x*10)+(n%10); n=n/10; } return x; }
19th Sep 2019, 9:05 AM
nidhi