Pattern Printing:Star and Half pyramid in C

#include<stdio.h>
int main()
{
    int i,j,rows;
    printf("Enter the number of rows: ");
    scanf("%d",&rows);
    for(i=1; i<=rows; i++)
    {
        for(j=0; j<i; j++)
        {
            printf("*");

        }
        printf("\n");
    }
    return 0;
}

Output

Enter the number of rows: 5
*
**
***
****
*****

Process returned 0 (0x0)   execution time : 1.769 s
Press any key to continue.

 

Code:

#include<stdio.h>
int main()
{
    int i,j,rows;
    printf("Enter the number of rows: ");
    scanf("%d",&rows);
    for(i=1; i<=rows; i++)
    {
        for(j=0; j<=i; j++)
        {
            printf("*");

        }
        printf("\n");
    }
    return 0;
}

 

Output:

Enter the number of rows: 5
**
***
****
*****
******

Process returned 0 (0x0)   execution time : 1.865 s
Press any key to continue.

References:

http://www.codeforwin.in/2015/07/star-patterns-program-in-c.html

http://www.tutorial4us.com/cpp-program/cpp-program-print-triangle-of-stars

http://www.programmingsimplified.com/c-program-print-stars-pyramid

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *