The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Hollow Pyramid Star Pattern

In most of the MNC interview questions such as in ZOHO interview questions, IVTL Infoview interview questions, Amazon interview questions, GOOGLE interview questions, Infosys interview questions and even in Voonik interview questions, we come across star pattern questions with a probability of 1:5. We provide you a most commonly asked hollow pyramid star pattern question for your interview preparation using C programming.

Lets code a C program to print hollow pyramid star pattern to have some fun

Hollow Pyramid Star Pattern

We challenge you, the programmer to do the hollow pyramid star pattern using C programming

Hollow Pyramid Star Pattern in C
hollow-pyramid-star-pattern.c
#include<stdio.h>
int main()
{
int i, j, k, num;
printf("Enter a number : ");
scanf("%d", &num);
printf("\n");
for(i = 1; i <= num; i++)
{
for(k = 0; k < num-i; k++)
{
printf(" ");
}
for(j = 1; j <= (2 * i - 1); j++)
{
if(i == num || j == 1 || j == (2*i-1))
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Enter a number: 5
    *
   * *
  *   *
 *     *
*********

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report