This repository has been archived by the owner on Dec 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from vaibhavx42/pattern
Created full pyramid Pattern
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-Question will be to print full pyramid taking rows as an input from the user | ||
|
||
* | ||
* * * | ||
* * * * * | ||
* * * * * * * | ||
* * * * * * * * * | ||
|
||
- > Program - > | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int space, rows; | ||
|
||
cout <<"Enter number of rows: "; | ||
cin >> rows; | ||
|
||
for(int i = 1, k = 0; i <= rows; ++i, k = 0) | ||
{ | ||
for(space = 1; space <= rows-i; ++space) | ||
{ | ||
cout <<" "; | ||
} | ||
|
||
while(k != 2*i-1) | ||
{ | ||
cout << "* "; | ||
++k; | ||
} | ||
cout << endl; | ||
} | ||
return 0; | ||
} |