1//WAP to print triangle pattern... LOGIC
2int num{}, i{1};
3 cin >> num;
4 while (i <= num) {
5 for (int space = 1; space <= (num - i); space++) { // space
6 cout << " ";
7 }
8 for (int value = 1; value <= (2 * i - 1); value++) { // value
9 cout << value;
10 }
11 cout << endl; //next row
12 i++;
13 }
1//C++ program to display hollow star pyramid
2
3#include<iostream>
4using namespace std;
5
6int main()
7{
8 int rows, i, j, space;
9
10 cout << "Enter number of rows: ";
11 cin >> rows;
12
13 for(i = 1; i <= rows; i++)
14 {
15 //for loop to put space in pyramid
16 for (space = i; space < rows; space++)
17 cout << " ";
18
19 //for loop to print star
20 for(j = 1; j <= (2 * rows - 1); j++)
21 {
22 if(i == rows || j == 1 || j == 2*i - 1)
23 cout << "*";
24 else
25 cout << " ";
26 }
27 cout << "\n";
28 }
29 return 0;
30}
31