DONSTORM PYRAMID PATTERN IN C PROGRAMMING GREPPERS code example

Example 1: c programming print pattern pyramid

#include<stdio.h> 
int main() 
{
int i,j,n; 
printf("ENTER THE NUMBER OF ROWS YOU WANT TO PRINT * PYRAMID PATTERN\n"); 
scanf("%d", &n); 
for(i = 1 ; i <= n ; i++) 
{
    for (j = 1 ; j <= 2*n-1 ; j++) 
{
      if (j >= n-(i-1) && j <= n+(i-1)) 
      { printf("*"); }
      else 
      {printf(" "); } 
} 
printf("\n");
}

Example 2: half pyramid in c

#include <stdio.h>
#define N 5
int main()
{
	int i,j;
	for(i=1;i<=N;i++)
		{
  			for(j=1;j<=i;j++)
    		printf("*");
  
  		printf("\n");
		}
  return 0;
}

Tags:

C Example