Print the patterns | user given limit | C-Program

Print Patterns by nested 'for' loop:


Pattern 1:

*
**
***
****
*****
******
-------------

Code:

#include<stdio.h>

int main()

{
    int i, j, stair;

    printf("Enter number of stair: ");

    scanf("%d",&stair);

    for(i=1; i<=stair; i++)

    {
        for(j=1; j<=i; j++)

        {
            printf("* ");
        }

        printf("\n");
    }

} 

Pattern 2:

--------------
*******
******
*****
****
***
**
*

Code:

#include<stdio.h>

int main()

{
    int i, j, stair;

    printf("Enter number of stair: ");

    scanf("%d",&stair);

    for(i=stair;i>=1;  i--)

    {
        for(j=i;j>=1; j--)

        {
            printf("* ");
        }

        printf("\n");
    }

} 


Comments

Post a Comment

Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :