Pattern 9: C Program to print ‘K’ type Star Pattern

Spread the love

Write a C Program to print below pattern ( K pattern ) :

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

* *    

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

Note : This is one the series of pattern programs in C.

Program:
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,j,k,n;
  5.     printf(“Enter the Value for n : “);
  6.     scanf(“%d”,&n);
  7.     for(i=-n;i<=n;i++) // Note that ‘i’ is starting from -n (negative n)
  8.     {
  9.         k=i;
  10.         if(k<0)
  11.             k= k*-1;
  12.         for(j=0;j<=n;j++)
  13.         {
  14.             if(k>=j)
  15.                 printf(“* “);
  16.             else
  17.                 printf(” “);
  18.         }
  19.         printf(n);
  20.     }
  21.         return 0;
  22. }

Output:

Similar Star pattern programs:

More C programs:

C Tutorials with simple Examples:

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply