So the problem is to use nested for loops statements to draw triangles of "*"s. The number of "*"s on the last row is input from the user (valid range: 5 to 21).
Sample dialog:
Drawing triangles program.
How many triangles? 2
How many stars/last row (5-21)? 25
Out of range. Reenter: 7
*
**
***
****
*****
******
*******
How many stars/last row (5-21)? 5
*
**
***
****
*****
Press any key to continue
however when i use
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main()
{
int stars=1;
for(int line=0; line < 3; line++)
{
for(int s=0; s < stars; s++)
cout << "*";
stars+=2;
cout << endl;
}
return(0);
}
my output is
*
***
*****
how do i get it to look like the example? is there another code I should use??
Ur actually right I didn't do it by myself I got help from some one who couldn't answer the question this thread is about and neither did u so ur point of responding was for what? Because u were bored I assume. Regardless of your reasoning you have a wonderful day.
@ OP: moorecm is right in that we don't post answers to problems that seem like they are school work. There may be a few differences in philosophy here but pretty much universally the go-to guys agree on this.
The point of my post is not to cause a fuss but rather to make it clear that we (go-to guys?) were not born yesterday. We are more than willing to help but often enough posters try to take advantage.
all i needed is help with was basically what do i need to do, for a users input to make the last row of the triangle. So i came here to see if anyone can help me, NO i dont know the code,and NO i dont know where to start looking for it at.