[Solved] How do I generate number pattern in triangular form


Fairly simple: use two loops, one for counting up and one for counting down. Print literal "0" between the two.

#include <stdio.h>

int main()
{
    for (int i = 0; i < 10; i++) {
        for (int j = 10 - i; j < 10; j++)
            printf("%d", j);

        printf("0");

        for (int j = 9; j >= 10 - i; j--)
            printf("%d", j);

        printf("\n");
    }

    return 0;
}

4

solved How do I generate number pattern in triangular form