hi I am trying to make a program to create a triangle of #'s but I can't get setw to work
here is my code:
here is my code:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
int row = 0;
int numSymbols = 1;
int counter;
int length;
int numspace;
numspaces = length;
cin >> length;
while( row < length )
{
// output spaces
cout << setw( numspace );
// output pound signs
counter = 0;
while( counter < numSymbols )
{
cout << "#";
counter++;
} // end while
cout << endl;
// decrease number of spaces
numSpaces--;
// increase number of symbols to display
numSymbols = numSymbols + 1;
// go to next row
row++;
}
return 0;
}