Pages

Wednesday, March 26, 2025

code to print in reversed manner using while loop in C++

 #include <iostream>

using namespace std;

// code to print reverse manner
int main(){
    int n = 10829;

    while(n > 0){ // infinite loop until all digits are checked
        int lastDig = n % 10; // gets last digit
        cout << lastDig << " ";
        n /= 10; // removes the last digit, keeps remaining
    }

    return 0;

}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...