Skip to content
Home » C program to print full diamond of stars

C program to print full diamond of stars

Learn about C program to print full diamond of stars in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C program to print full diamond of stars

To print the below pattern run the below C program with required number of rows.

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

Program:

#include<stdio.h>
int main()
{
   int n;

   printf("Enter N value: ");
   scanf("%d",&n);

   for(int i=1; i<=n; i++)
   {
     for(int j=i; j<=n; j++)
     {
       printf(" ");
     }
     for(int k=1; k<=2*i-1; k++)
     {
       printf("*");
     }
     printf("\n");
   }

   for(int i=n-1; i>=1; i--)
   {
     for(int j=n; j>=i; j--)
     {
       printf(" ");
     }
     for(int k=1; k<=2*i-1; k++)
     {
       printf("*");
     }
     printf("\n");
   }

   return 0;
}

Output:

Enter N value: 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 :
C program to print half diamond of numbers
C program to print half diamond of numbers