Pyramid pattern || Special Character (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 Triangle of Multiple special characters, with the help of the C Programming language.




#include <stdio.h>

int main()
{
    int i, j, k, l, n;
    printf("Enter the Range\n");
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n - i; j++)
        {
            printf(" ");
        }
        for (k = 1; k <= i; k++)
        {
            if (i % 2 == 0)
            {
                printf("#");
            }
            else
                printf("&");
        }
        for (l = i - 1; l >= 1; l--)
        {
            if (i % 2 == 0)
            {
                printf("#");
            }
            else
                printf("&");
        }
        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