Hourglass pattern program in c programming language

Hourglass Star Pattern Program In C programming language

Social Shares
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Hello readers, today you are going to learn how to print hourglass pattern program in c programming language. Before start print hourglass pattern we need to know how looping statement works because looping statements like for loop or while loop plays a very important role to make a pattern program in c. If you have good knowledge of looping statements in c language then you can go with this session. So let’s get started.

Video Of Hourglass Star Pattern Program In C

 

Source Code Of Hourglass Star Pattern Program In C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,num;
clrscr();
printf("Enter any value : \t");
scanf("%d",&num);

for(i=-num;i<=num;i++)
{
if(i==0)
continue;
k=i;
if(k>0)
{
k = k * -1;
}
for (j = 0; j < num; ++j)
{
if (j < (k+num))
{
printf(” “);
}
else
{
printf(“* “);
}
}
printf(“\n”);
}
getch();
}

 

I hope you understand how to print diamond pattern program in c. If you understand then please share my hard work with your friends. Subscribe my newsletter for upcoming article’s updates direct in your mailbox. If you have any confusion or query then you can leave a message on my facebook page. At last, I would like to say please don’t forget to subscribe to my youtube channel. Thank you for visiting.


Social Shares
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

4 comments

Leave a Reply

Your email address will not be published. Required fields are marked *