How to Solve a Computer Science C++ Problem?

In summary, the conversation is about a programming problem involving for loops. The initial code provided only prints four blank spaces per line, and the person needs to change the test condition and associate it with the lineCtrl variable in order to print the correct number of X's per line. The person is struggling with this concept but eventually figures it out on their own.
  • #1
ZincPony
21
0
Problem Solved thank you
 
Last edited:
Physics news on Phys.org
  • #2
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.
 
  • #3
doing the 2*lineCtrl-1 send it into an infinite X printing loop.
 
  • #4
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:
 
  • #5
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.
 
  • #6
never mind i figured id it out.

thank you
 

Attachments

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

Related to How to Solve a Computer Science C++ Problem?

1. What is Computer Science C++ Problem?

Computer Science C++ Problem refers to a specific problem or challenge that needs to be solved using the C++ programming language. It could involve writing code to perform a certain task, troubleshooting errors, or optimizing existing code.

2. What is C++ programming language?

C++ is a high-level, general-purpose programming language that was developed in the 1980s as an extension of the C programming language. It is used for developing a wide range of applications, including operating systems, video games, and desktop applications.

3. How do I solve a Computer Science C++ Problem?

To solve a Computer Science C++ Problem, you will need to have a strong understanding of the C++ programming language and its syntax. You will also need to be familiar with problem-solving techniques and algorithms. It is important to break down the problem into smaller, manageable steps and test your code as you go.

4. What are common challenges in solving Computer Science C++ Problems?

Some common challenges in solving Computer Science C++ Problems include syntax errors, logic errors, and run-time errors. It is also important to consider efficiency and optimization when writing code, as well as handling input and output correctly.

5. How can I improve my C++ problem-solving skills?

To improve your C++ problem-solving skills, it is important to practice regularly and work on a variety of different problems. You can also read books, attend workshops or online courses, and collaborate with other programmers to learn new techniques and strategies. Analyzing and understanding existing code and debugging errors can also help improve your skills.

Similar threads

  • STEM Academic Advising
Replies
3
Views
856
  • New Member Introductions
Replies
3
Views
80
  • General Discussion
Replies
1
Views
328
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • New Member Introductions
Replies
1
Views
95
  • Programming and Computer Science
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
17
Views
1K
  • New Member Introductions
Replies
2
Views
49
  • STEM Academic Advising
Replies
6
Views
1K
Replies
1
Views
46
Back
Top