-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA10patterndisplay.cpp
More file actions
46 lines (38 loc) · 848 Bytes
/
A10patterndisplay.cpp
File metadata and controls
46 lines (38 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Pattern Display
// By Emily Dayanghirang
#include <iostream>
using namespace std;
int main()
{
int numberOfRows;
/*
* Prompt user to choose the number
of rows of the pattern that will
be displayed
* Re-prompt when user's input is less than 1
or greater than 20
*/
do
{
cout << "Select the pattern's number of rows from 1 to 20: ";
cin >> numberOfRows;
cout << endl;
} while (numberOfRows < 1 || numberOfRows > 20);
// Display pattern
for (int i = 0; i < numberOfRows; i++)
{
for (int j = 0; j <= i; j++)
{
if (i == j)
{
cout << "#";
}
else
{
cout << "*";
}
}
cout << endl;
}
return 0;
}