Star Pattern 4 – Diamond shape pattern in C programming language

Spread the love

Diamond shape pattern in C programming language

Diamond shape pattern in C programming language

In this program, we will see the diamond shape pattern in C programming. Or the pattern with two opposite full triangle connected by there bottoms.

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

The C program for above diamond shape pattern is as follows:

#include<stdio.h>


int main()
{
 int i,j, no_rows;
 int spaces = 4;

 printf("Enter number of rows for pattern = "); 
        scanf("%d",&no_rows); 
 
 for(i=0;i< no_rows;i++)
 {
  
  for(j=0;j< spaces;j++)
  {
   printf(" ");
  }
  for(j=0;j<=i;j++)
  {
   printf("* ");
  }
  
  printf("n");
  spaces--;
 }
 
 spaces = 0;
 
 for(i = no_rows;i>0;i--)
 {
  
  for(j=0;j< spaces;j++)
  {
   printf(" ");
  }
  for(j=0;j< i;j++)
  {
   printf("* ");
  }
  
  printf("n");
  spaces++;
 }
 getch();
     return 0;
}

Number Series Programs in C programmming

Star Pattern Programs in C programmming

Number Pattern Programs in C programmming

Alphabet Pattern Programs in C programmming


Spread the love

Leave a Comment