Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pattern4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
***
*
*/

// nRows => number of rows
// nSpace => number of space between two stars
//symbol => if want unique symbool then can provide otherwise it will take astrik/star
#include <iostream>
using namespace std;

Expand All @@ -20,12 +22,22 @@ int main() {
}

int nSpace=0;
char symbol = "*";
char ans = "n";
cout<<" \n Do you want some symbol, By default its astrik/star (y/n) : ";
cin>>ans;
if(ans == "y" || ans == "Y" || ans == "yes" || ans == "YES")
{
cout<<"\n Enter the symbol for pattern, By default its star/astrik ";
cin>>symbol;
}

for (int i=nRows; i>=1; i--) {
for (int k=nSpace; k>=1; k--) {
cout << " ";
}
for (int j=(2*i-1); j>=1; j--) {
cout << "*";
cout << symbool;
}
cout << "\n";
nSpace++;
Expand Down