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

1 Answer

0 votes
#include <stdio.h>

int main() {
    int n = 0;

    for (int i = 4; i > 0; i--) {
        for (int j = 0; j < i; j++) {
           printf("%d", n);
        }
        printf("\n");
        n++;
    }
}



/*
run:

0000
111
22
3

*/

 



answered Mar 6, 2022 by avibootz
edited Mar 24, 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 319 views
1 answer 148 views
...