Write a C program to print the Hollow Left Pascal Triangle Star Pattern using for loop, while loop, and functions with an example. The below Hollow Left Pascal program uses the multilevel nested for loops to print the star pattern.
#include<stdio.h>
void loopLogic(int rows, int i)
{
for (int j = i; j < rows; j++)
{
printf(" ");
}
for (int k = 1; k <= i; k++)
{
if (k == 1 || k == i )
printf("* ");
else
printf(" ");
}
printf("\n");
}
int main(void)
{
int i, rows;
printf("Enter Rows to Print Hollow Left Pascal Triangle = ");
scanf("%d", &rows);
for (i = 1; i <= rows; i++)
{
loopLogic(rows, i);
}
for (i = rows - 1; i >= 1; i--)
{
loopLogic(rows, i);
}
}

C Program to Print Hollow Left Pascal Triangle Star Pattern using while loop
We replaced the the C language for loop with the C programming while loop in this Hollow Left Pascal Triangle Star Pattern program.
#include<stdio.h>
void loopLogic(int rows, int i)
{
int j = i;
while (j < rows)
{
printf(" ");
j++;
}
int k = 1;
while (k <= i)
{
if (k == 1 || k == i )
printf("* ");
else
printf(" ");
k++;
}
printf("\n");
}
int main(void) {
int i, rows;
printf("Enter Rows to Print Hollow Left Pascal Triangle = ");
scanf("%d", &rows);
i = 1;
while ( i <= rows ) {
loopLogic(rows, i);
i++;
}
i = rows - 1;
while ( i >= 1 ) {
loopLogic(rows, i);
i--;
}
}
Output. Refer to the C programs page.
Enter Rows to Print Hollow Left Pascal Triangle = 12
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
In the below Hollow Left Pascal Triangle Stars pattern program, the function accepts the rows and characters to print the pattern using the symbol. For more star pattern examples, please refer to the C Star Pattern Programs article.
#include<stdio.h>
void loopLogic(int rows, int i, char ch)
{
for (int j = i; j < rows; j++)
{
printf(" ");
}
for (int k = 1; k <= i; k++)
{
if (k == 1 || k == i )
printf("%c ",ch);
else
printf(" ");
}
printf("\n");
}
int main(void)
{
int i, rows;
char ch;
printf("Enter Character = ");
scanf("%c", &ch);
printf("Enter Rows to Print Hollow Left Pascal Triangle = ");
scanf("%d", &rows);
for (i = 1; i <= rows; i++) {
loopLogic(rows, i, ch);
}
for (i = rows - 1; i >= 1; i--) {
loopLogic(rows, i, ch);
}
}
Output
Enter Character = $
Enter Rows to Print Hollow Left Pascal Triangle = 15
$
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$ $
$
Also Read
- C Program to Print Hollow Right Pascal Triangle Star Pattern
- C Program to Print Christmas Tree Star Pattern