Skip to content
Home » Start Pattern Program in C

Start Pattern Program in C

Learn about Start Pattern Program in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Start Pattern Program in C

Pattern: To print the below pattern in C programming then run the below code.

    *
   ***
  *****
 *******
*********

Program:

#include<stdio.h>
int main()
{
    int n, r, c, s;

    printf("Enter number of rows: ");
    scanf("%d",&n);

    for(r=1;r<=n;r++)
    {
      for(s=1;s<=n-r;s++) printf(" ");
      for(c=1;c<=(2*r-1);c++) printf("*");

      printf("\n");
    }

    return 0;
}

Output:

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

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Pattern Program 17 in C
Pattern Programs 16 in C