| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Syntax errors - Help needed with program
hello everyone i hope i can find help here since i am a beginner in C++ i need help with this
i have this source code so far but i want it to display : * ** *** **** ***** ---------------------------------------------- #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--) { drawBar(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) { theCounter--; std::cout << '*'; } std::cout << '\n'; return 0; } //end drawBar ---------------------------------------- how can i do that i dont seem to understand where the problem is since i get only : * thanks in advance |
|
#2
|
|||
|
|||
|
try changing
int triangleBase = 0; to int triangleBase = 10; Then, decide wether you want drawbar to count up or down - the code now tries a little bit of both, and turns everything into a mess as a result.
__________________
Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Syntax errors - Help needed with program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|