-
need help on program...
Ive been told to do a program which outputs the following:
*
**
***
****
*****
I know it involves using three loops that look like this:
for(int i=1;i<=5;i++)
{
for(int j=i;j<=5;j++)
{
cout<<" ";
}
for(???????)
{
cout<<*;
}
cout<<endl;
}
can someone please tell me if im close, and if so what this third loop needs to contain? ive been trying to do it for a while now, and no matter what i put in that third loop it always runs infinitely.
thanks~
-
more...
for some reason when i posted it altered the triangle i needed...
since it wont let me display, ill descobe it...
it consists of a block pretty much, where it has 4 spaces and 1 star for the first row, then 3 spaces and 2 stars for the second...etc,etc...pretty much the one displayed, but reversed.
thanks~
-
for(int i=1;i<=5;i++)//which line
{
for(int j=i;j< 5;j++) //max 4 spaces per line
{
cout<<" ";
}
for(int k = 1; k <= i; k++)//max 5 * per line
{
cout<<'*';
//etc.
-
or you could just cheat...
cout << "*\n";
cout << "**\n";
cout << "***\n";
cout << "****\n";
cout << "*****\n";