Comp Sci How to Solve a Computer Science C++ Problem?

AI Thread Summary
The discussion revolves around solving a C++ problem involving loops and printing patterns. A participant shares a solution that involves adjusting the loop conditions to print the desired number of spaces and characters. They emphasize the importance of correctly associating the loop variables and avoiding infinite loops by properly calculating the number of characters to print. Another participant, who is new to C++, expresses their struggle with the concepts but eventually figures out the solution on their own. The conversation highlights the learning process in programming and the importance of understanding loop mechanics.
ZincPony
Messages
21
Reaction score
0
Problem Solved thank you
 
Last edited:
Physics news on Phys.org
for (int spaceCtrl = 4; spaceCtrl >=1 ; spaceCtrl--)
This will just print 4 blanks every line. That is you need to change the test condition and associate it with lineCtrl variable.

for (int xCtrl = 1; xCtrl <= lineCtrl; ++xCtrl)
Remember you need 2*lineCtrl-1 X's in each line.
 
doing the 2*lineCtrl-1 send it into an infinite X printing loop.
 
Seems to work fine for me. I am not giving you the code just yet. Why don't you post your revised code? And mind your braces :smile:
 
hey man this is my first C++ class in the summer which means its accelerated. soo he just introduced for loops in wed class soo I am trying to create this from it. I am stumped. can you give me a lil bit of a bigger clue to go from.
 
never mind i figured id it out.

thank you
 

Attachments

  • final.JPG
    final.JPG
    13.4 KB · Views: 410
Last edited:

Similar threads

Back
Top