1/**
2 * C program to print hollow mirrored right triangle star pattern
3 */
4
5#include <stdio.h>
6
7int main()
8{
9 int i, j, rows;
10
11 /* Input rows from user */
12 printf("Enter number of rows : ");
13 scanf("%d", &rows);
14
15 /* Iterate through rows */
16 for(i=1; i<=rows; i++)
17 {
18 /* Print trailing spaces */
19 for(j=i; j<rows; j++)
20 {
21 printf(" ");
22 }
23
24 /* Print hollow right triangle */
25 for(j=1; j<=i; j++)
26 {
27 /*
28 * Print star for last row(i==row),
29 * first column(j==1) and
30 * last column(j==i).
31 */
32 if(i==rows || j==1 || j==i)
33 {
34 printf("*");
35 }
36 else
37 {
38 printf(" ");
39 }
40 }
41
42 printf("\n");
43 }
44
45 return 0;
46}
47Output