Follow This Blog For more... 😊

Program to print triangle(◤) Pattern:2 | Using C language| C Program series 23|

👨‍💻Program to print triangle() Pattern:2.

Code 1 :

For FIXED LINENS:


    /*
   
    Pattern 2
    *****
    ****
    ***
    **
    *
   
    */

    #include<stdio.h>
    main()
    {
        printf("Pattern 2\n\n");
       
        int i,j;
        //i for row
        //j for column
       
        for(i=1;i<=5;i++)
        {
            for(j=5;j>=i;j--)
            {
                printf("*");
            }
            printf("\n");
        }
    }

The Output of code 1:


👨‍💻Program to print triangle() Pattern:2 for n number of lines.

Code 2 :

For n number of LINENS:

   
    /*
    Program to print triangle Pattern:2 for n number of lines.
    For Example:n=10
    **********
    *********
    ********
    *******
    ******
    *****
    ****
    ***
    **
    *
   
    */
    #include<stdio.h>
    main()
    {
        printf("Program to print triangle Pattern:2 for n number of lines.\n\n");
       
        int i,j,n;
        //n for number
        //i for row
        //j for colomn
       
        printf("Enter the number:");
        scanf("%d",&n);
       
        for(i=1;i<=n;i++)
        {
            for(j=n;j>=i;j--)
            {
                printf("*");
            }
            printf("\n");
        }
    }

The output of Code 2:




👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts