Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (1018):

Can anyone help my in my c++ assignment? In kinda goes like this: I need this output. I'll jut draw it here:

OpenStudy (1018):

|dw:1376581172227:dw|

OpenStudy (1018):

But another thing is that I need the user's input. So the choice is for the user to choose # or * for the characters, then if its decreasing or increasing, or starting from left or right. so I need these outputs:

OpenStudy (anonymous):

okay i am assuming you are a complete newbie to C++ so here's a direct example, just check it before implementing. i may be wrong. #include <iostream> using namespace std; int main() { int rows,i,j,k=0; cout<<"Enter number of rows: "; cin>>rows; for(i=1;i<=rows;i++) { for(j=1;j<=i;++j) cout<<k+j<<" "; ++k; cout<<endl; } return 0; }

OpenStudy (e.mccormick):

siddhantk3m8's example has a couple of issues, the biggest being it does not let you select the character to repeat. However, the basic principal is there for the core idea: use nested loops to make the pyramid. For getting the type of character to repeat you have a few options. You could take in the character directly so it would repeat anything, you could just take in # or * as possible options, or you could make something like "Select a or 1 for * (asterisk.)\nSelect p or 2 for # (pound.)." Once you know what they want to repeat, you just store that in a variable to be output for however many rows they want.

OpenStudy (theeric):

And you'll need to make sure you can do everything else, too. You said increasing/decreasing and left/right, right? I'll use "_" to show a space. Given 3 rows and using the #, the output could be: left, increasing # ## ### right, increasing __# _## ### left, decreasing ### ## # right, decreasing ### _## __# There are many ways to do this, too. In increasing, you print one symbol in the first row, and print one more in each next row until the number of rows has been reached (and the number of rows is the number of symbols). If decreasing, you print the entire first row as symbols, and as many symbols as rows. That's just the relationship I see among numbers. Then you print one less in each next row. If printing a left-starting row, just print the number of symbols. If printing a right-starting row, print the spaces (the number of rows/columns minus the number of symbols for that row), then print the symbols.

OpenStudy (1018):

Hey, thanks guys. Although my thank you is 2 weeks late, but still. Lol. I've done the program. Still, thank you!

OpenStudy (e.mccormick):

Good! And don't forget to close the question. (Upper left)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!