Pyramid pattern || Number (Type 2) || Pattern || for loop || C Programming


This is a nested for loop program in which we are going to see how to print the above pattern of pyramid/triangle of numbers in reverse order, with the help of the C Programming language.




#include <stdio.h>

int main()
{
    int i, j, k, l, n;
    printf("\nEnter the Range\n");
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n - i; j++)
        {
            printf(" ");
        }
        for (k = i; k >= 1; --k)
        {
            printf("%d", k);
        }
        for (l = 2; l < i + 1; ++l)
        {
            printf("%d", l);
        }
        printf("\n");
    }
    return 0;
}


#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post