I need my output screeen to looklike this. So far i can do all of it except my traingle comes out in a right angle and i dont know how to make it into an traingle shown below. Ive tried usind 'setw" but it doesnt seem to be working.

This project will make a triangle using any symbol of your choosing.

Do you wish to continue? (y = yes, n = no): y

Enter the symbol to be used to draw the triangle: *
How many lines do you want the triangle to be? 7

*
***
*****
*******
*********
***********
*************

Thank you for using this program.

my Triangle comes out like this:
*
***
*****
*******
*********
*************

Well posting some code which "doesn't seem to work" would be a big help.

It would make it look like you were making an effort, and not looking to score some free homework.

Oh, and let's see if you can post code and use code tags like endless readme's tell you to.

Edited 3 Years Ago by happygeek: fixed formatting

#include <iostream>
#include <iomanip> // required for parameterized stream manipulators


using namespace std;




int main()

{
  int numLines;                           //user entered total number of lines to be drawn
  char symbol;                                       //user entered symbol to be used
  char userwantsto;                //do you wish to continue?
  int lineCounter;                     //counter to determine what line is being drawn
  int numSymbols;                  //counter to determine how many symbols drawn
  int numSymbolsNeeded = 1;                     //counter to determine the total number of symbols
                                        //to be drawn on that line
  int Margin;



  cout << "This application will take any symbol\n of your choosing and make a triangle.You can also\ndecide how large you want the triangle to be by\nentering how many lines long you want the triangle to be.\nPress any key to continue.  \n\n"<<endl<<endl;

  cout << "Do you wish to continue? (y = yes, n = no):  ";
   cin.sync();
   cin.get(userwantsto);
   userwantsto = tolower(userwantsto);  

while (userwantsto != 'y' && userwantsto != 'n')
   {
      cout << "Invalid response.  Enter a y for yes or n for no: ";
      cin.sync();          // clear out buffer
      cin.clear();          // set for a good read
      cin.get(userwantsto);

   }

     if (userwantsto == 'n')

    return 0;

     cout << "\n\nEnter the symbol to be used to draw the triangle: ";
     cin.sync();
     cin.get(symbol);

     cout << "How many lines do you want the triangle to be? ";
     cin >> numLines;

            while (!cin || numLines <= 0 || numLines > 80)   //invalid input was entered

            {
             cout << "Invalid response, the number of lines must be an integer " << endl
             << "between 1 and 80, try again:"  ;
             cin.sync();
             cin.clear();
             cin >> numLines;

            }



            //this first for loop controls the number of lines of the triangle
            //after each pass, the lineCounter is incremented until it is equal to
            //the appropriate number of lines entered by the user.


            for ( lineCounter = 1; lineCounter <= numLines; lineCounter++)
cout << endl; 
setw(9);

            { 


                for (numSymbols = 0; numSymbols < numSymbolsNeeded; numSymbols++)

                {
                  cout << symbol;                  //add 1 symbol at a time on the same line
                                                   //until the number of symbols written is
                                                   //equal to the number of symbols needed
                                                   //for this line.
                }


                        cout << endl;                                    //go to the next line
                        numSymbols = 0;                                  //increment the number of symbols to
                        numSymbolsNeeded++;                              //be displayed on the next line by 1



            }
            return 0;

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Congratulations - you failed to comprehend code tags. So now you'll have to wait for a mod to fix the mess you posted, and then maybe someone will read it.

Sometimes, it's just like trying to teach rocks to fly.

Comments
Haha, I agree there :)
#include <iostream>
#include <iomanip> // required for parameterized stream manipulators


using namespace std;




int main()

{
int numLines; //user entered total number of lines to be drawn
char symbol; //user entered symbol to be used
char userwantsto; //do you wish to continue?
int lineCounter; //counter to determine what line is being drawn
int numSymbols; //counter to determine how many symbols drawn
int numSymbolsNeeded = 1; //counter to determine the total number of symbols
//to be drawn on that line
int Margin;



cout << "This application will take any symbol\n of your choosing and make a triangle.You can also\ndecide how large you want the triangle to be by\nentering how many lines long you want the triangle to be.\nPress any key to continue. \n\n"<<endl<<endl;

cout << "Do you wish to continue? (y = yes, n = no): ";
cin.sync();
cin.get(userwantsto);
userwantsto = tolower(userwantsto);

while (userwantsto != 'y' && userwantsto != 'n')
{
cout << "Invalid response. Enter a y for yes or n for no: ";
cin.sync(); // clear out buffer
cin.clear(); // set for a good read
cin.get(userwantsto);

}

if (userwantsto == 'n')

return 0;

cout << "\n\nEnter the symbol to be used to draw the triangle: ";
cin.sync();
cin.get(symbol);

cout << "How many lines do you want the triangle to be? ";
cin >> numLines;

while (!cin || numLines <= 0 || numLines > 80) //invalid input was entered

{
cout << "Invalid response, the number of lines must be an integer " << endl
<< "between 1 and 80, try again:" ;
cin.sync();
cin.clear();
cin >> numLines;

}



//this first for loop controls the number of lines of the triangle
//after each pass, the lineCounter is incremented until it is equal to
//the appropriate number of lines entered by the user.


for ( lineCounter = 1; lineCounter <= numLines; lineCounter++)
cout << endl;
setw(9);

{


for (numSymbols = 0; numSymbols < numSymbolsNeeded; numSymbols++)

{
cout << symbol; //add 1 symbol at a time on the same line


}


cout << endl; //go to the next line
numSymbols = 0; //increment the number of symbols to
numSymbolsNeeded++; //be displayed on the next line by 1



}
return 0;
for ( lineCounter = 1; lineCounter <= numLines; lineCounter++)
cout << endl;
setw(9);

{

The opening brace is in the wrong place. It should be right after the for loop stuff:

for ( lineCounter = 1; lineCounter <= numLines; lineCounter++)
{
cout << endl;
setw(9);

//{

If the braces are omitted from a loop, then the next single statement constitutes the whole of the loop. Your compiler sees this with your code:

for ( lineCounter = 1; lineCounter <= numLines; lineCounter++)
{
    cout << endl;
}

setw(9);

{

That's why it prints a bunch of blank lines and then a single symbol.

This article has been dead for over six months. Start a new discussion instead.