My code works fine, but I cannot seem to figure out where I am getting the repeat of triangles. I have to only have one set show, but for some reason I get a repeat of triangles going down at least 5 to 6 times in a column, could someone help me out with where I am wrong in this code. It does work but I get it repeating it when it should be only once.
CODE
# include <iostream>
using namespace std;
void drawBar(int userInput);
void printTriangle(int userInput);
int main ()
{
int userInput = 0;
cout << "Enter the triangle base size: ";
cin >> userInput;
drawBar(userInput);
printTriangle(userInput);
return 0;
}
//Function Definitiion
void drawBar(int userInput)
{
for (int a = 1; a <= userInput; a++)
{
printTriangle(userInput);
}
cout << endl;
}
void printTriangle(int userInput)
{
for (int a = 1; a <= userInput; a++)
{
for (int b = 1; b <= a; b++)
{
if (b <= userInput)
cout << "*";
else
cout << "";
}
cout << endl;
}
}