How to print 0000 111 22 3 using for loop in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int n = 0;
    
    for (int i = 4; i > 0; i--) {
        for (int j = 0; j < i; j++) {
           std::cout << n;
        }
        std::cout << '\n';
        n++;
    }
}
 
 
 
 
/*
run:
 
0000
111
22
3
 
*/

 



answered Mar 6, 2022 by avibootz

Related questions

1 answer 138 views
1 answer 122 views
1 answer 145 views
1 answer 156 views
1 answer 144 views
1 answer 113 views
113 views asked Mar 14, 2024 by avibootz
1 answer 171 views
171 views asked Jun 14, 2020 by avibootz
...