I have not worked with the debugger at all and I have a assignment to debug a program.
I don't want just the answer I need help using the debugger.
Correct the Logical errors in the code so that the output of the program appears as such:



* Programmer: [Rodney Garner]
* Date: [03/11/2011]
* Course: COMP 220
* Assignment: Identification and correction of logical errors
* Description: this program prints a triangle with a base of five asterisks 
* Output: screen - displays a triangle 

#include <iostream>

int drawBar(int);

int main()
     std::cout << std::endl << "Let's Draw a triangle!\n";

     //determine how many lines will be drawn
     int triangleBase = 0;

     //draw the triangle 
     for (int i = 0 ; i >= triangleBase ; i--) {

     return 0;
} //end main

int drawBar(int barSize) {
//draws a line of asterisks
//the number of asterisk drawn equals barSize

     int theCounter = 0;
     while (theCounter >= barSize) {
          std::cout << '*';
     std::cout << '\n';
     return 0;
} //end drawBar

Edited by mike_2000_17: Fixed formatting

7 Years
Discussion Span
Last Post by template<>

Take a good look at the for loop from line 29.If i is 0 and triangleBase is also 0 at the start of the loop .. well the loop just won't start.
After that at line 41 the while loop says that barSize must be a negative integer or zero in order that the loop should start which doesn't make sense in the context in which you want a sequence of one to five iterations.Just set the conditions properly.

Votes + Comments
That's more like it!

Ok so start the debugger and step through the code. If you never used it before get someone to walk you through it...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.