Enter a value to represent the base of a triangle shape (not to exceed 80): 11
Enter the character to be used to generate the triangle shape (for eg., #, * $): *
*
***
*****
*******
*********
***********Do you want to quit the program? (type n for no or q to quit): q
My incorrect source code to attempt to acheive this exact output so far is:
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main()
{
int stars=1;
int baseNumberStars;
char theSymbol;
string spaces = " ";
cout << "Enter a value to represent the base of a triangle shape (not to exceed 80): ";
cin >> baseNumberStars;
cout << "Enter the character to be used to generate the triangle shape (for eg., #, * $): ";
cin >> theSymbol;
if (baseNumberStars>80)
{
cout << "Please enter a number 1-80 for triangle's base.\n";
system("PAUSE");
return(1);
}
if((baseNumberStars>0) || (baseNumberStars<=80))
{
for(int line=-1; line < baseNumberStars; line++)
{
for(int s=(baseNumberStars-1); s < stars; s++)
cout <<theSymbol;
stars+=2;
cout << endl;
}
system("PAUSE");
return(0);
}
}
I am very new to loops and am learning them for the first time so bear with me...
The things I need to do left for my program are:
1. I need to get it so my triangle is no longer a right triangle.
2. I need to make it so at the end of the program when "n" is inputted it repeats the program.
Also, I am confused why there is a large space between my triangle and the words above it.
I may not respond for a few hours or so after this. Your guys help appreciated, thanks again.
2. I need to make it so at the end of the program when "n" is inputted it repeats the program.
Then read the input in a char(or any other thing), and break; the loop if q, do nothing if n, --optional-- or say something like "Wrong input" if any other character.
At last solution found!--at least for the second question.
The problem is that, the tip is not pointed, and it also doubles the base of the triangle.--Maybe someone might try to help "us" out?