Pages

Monday, March 31, 2025

Print the 0-1 Triangle Pattern in C++

 Print#include <iostream>

using namespace std;
int main() {
    // outer loop (rows) -> 1 to n
    for(int i = 1; i <= 5; i++){
        // numbers
        for(int j = i; j >= 1; j-- ){
            cout << j%2 << " ";
        }
        cout << endl;
    }
   
    return 0;
}


OUTPUT-
1 0 1 1 0 1 0 1 0 1 1 0 1 0 1

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...