anonymous
  • anonymous
How to generate a program in C++ that gives the output as follows - consider as dash. ----* ---*** --***** -******* *********
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
using a loop?
anonymous
  • anonymous
cout << "----*\n---***\n--*****\n-*******\n*********" << endl;
anonymous
  • anonymous
Use a for loop, or maybe a nestled for loop. You start with 4 underscores and decrement by one on each line. You add two asterisks on each line. Start the problem, post any further questions/problems you have.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
You should use a loop
anonymous
  • anonymous
There are many ways to do this, one of them is to store the content of each line in array/vector of strings and then perform the following code: copy(strTable.begin(), strTable.end(), ostream_iterator (cout, "\n")) // vector version or: copy(strTable, strTable+size, ostream_iterator (cout, "\n")) // array version -- you have to know how many elements you have
anonymous
  • anonymous
for (int i=0; i<5; i++) { for (int j=0; j<4; j++) { if (j < 4-i) cout << "-"; else cout << "**"; } cout << "*" << endl; }
anonymous
  • anonymous
Well, I, for one, think that providing a ready-made program as an answer to a question like this is not very helpful. Being able to copy&paste is not a skill you want to instill. Now, to the question itself: 1) Do you know how to output characters in C++? 2) Do you know how to use variables and loops? 3) What can you tell about the number of '-' and '*' characters in each row? How do they change? If you can answer these questions, you should be able to write your own program. Good luck!
anonymous
  • anonymous
Wops... I agree... I wrote it without actually thinking about it, but you're right.
anonymous
  • anonymous
u need to use for loop 3 times ,one for the space, one for the stars, and one for the rows
anonymous
  • anonymous
great, now try generating this: |*----| |-*---| |--*--| |---*-| |----*| |---*-| |--*--| |-*---| |*----| |-*---| ...

Looking for something else?

Not the answer you are looking for? Search for more explanations.