Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Reverse a Number

1 topic ยท 28 Nov 2026
1

Reverse a Number

Problem Solving

Take the last digit with % 10, add it to the result, then drop it with / 10.

C++
int n = 1234, rev = 0;
while(n != 0){
    int digit = n % 10;
    rev = rev * 10 + digit;
    n /= 10;
}
cout << rev; // 4321