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 232 views
1 answer 205 views
1 answer 254 views
1 answer 257 views
1 answer 222 views
1 answer 193 views
193 views asked Mar 14, 2024 by avibootz
1 answer 264 views
264 views asked Jun 14, 2020 by avibootz
...