Header Ads Widget

program to print the hourglass pattern | pattern printing in c

Here in this post we will write program to print the  Hourglass pattern for this we just have to manage the whitespaces . hourglass pattern is a type of pattern in which there is two type of triangles . below is the figure of hourglass pattern:-

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

program to print the hourglass pattern | pattern printing in c
Code:-

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

output:--

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

tags:-  hourglass pattern in c, inverted hourglass pattern in c, hourglass program in c, pattern hourglass coding blocks, pattern inverted hourglass coding blocks, sand glass star pattern in python, hourglass hackerrank solution in c, c program to print flag pattern, hourglass pattern in c++, inverted hourglass pattern in c++, hourglass program in c, pattern-hourglass coding blocks, pattern inverted hourglass coding blocks, sand glass star pattern in python,



Recommended Post:

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments