forked from panthji/cppprograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchandan3
More file actions
35 lines (31 loc) · 623 Bytes
/
chandan3
File metadata and controls
35 lines (31 loc) · 623 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
// C++ code to demonstrate star pattern
#include <iostream>
using namespace std;
// Function to demonstrate printing pattern
void pypart(int n)
{
// Outer loop to handle number of rows
// n in this case
int i = 0, j = 0;
while (i < n) {
// Inner loop to handle number of columns
// values changing acc. to outer loop
while (j <= i) {
// Printing stars
cout << "* ";
j++;
}
j = 0; // we have to reset j value so as it can
// start from begining and print * equal to i.
i++;
// Ending line after each row
cout << endl;
}
}
// Driver Code
int main()
{
int n = 5;
pypart(n);
return 0;
}