1. ## need help!

I have this program i need help with. i have to make a program that will display this.

000000*
00000***
0000*****
000*******
00*********
0***********
*************

//dont display the zeros.

using only one cout<<"*"; one cout" "; and use no tabs. any help would be great!

Im studying loops and i have

Code:
```#include <iostream>
using namespace std;

int main()
{
int r,s,spl,space;
spl = 7;

for(r = 1;r <= 7;r++)
{
for(space = 2;space <= spl;space++)
{
cout<<" ";
}
for(s = spl;s <= 7;s++)
{
cout<<"*";
}
spl--;
cout<<endl;
}
cin.ignore(2);
return 0;
}```
and the output is this:

000000*
00000**
0000***
000****
00*****
0******
*******

//agian for get the 0's

2. What are your thoughts on how to do this? What are you studying right now? Chances are it will be a test of that.

3. Im studying loops and i have

#include <iostream>
using namespace std;

Code:
```int main()
{
int r,s,spl,space;
spl = 7;

for(r = 1;r <= 7;r++)
{
for(space = 2;space <= spl;space++)
{
cout<<" ";
}
for(s = spl;s <= 7;s++)
{
cout<<"*";
}
spl--;
cout<<endl;
}
cin.ignore(2);
return 0;
}```
and the output is this:

000000*
00000**
0000***
000****
00*****
0******
*******

//agian for get the 0's

4. i havent really looked at the code, but its usually best to draw out your algorithm on paper first.

for the first line, you have 6 spaces then 1 *. second line you have 5 spaces then 3 *s. next line you have 4 spaces then 5 *s.

you may notice that if there are n spaces on the first line, there are n-1 spaces on the next line. also, if there are x *'s on the first line, there are (x + 2) *'s on the next line.

on your paper, write the algorithm thatll accomplish the first single line, which seems trivial. then modify it so that it prints the 2nd line properly, using variables rather than specific numbers (ie dont use 'print 5 spaces', etc). if it works for the second line, it should work for all subsequent lines.

hope it helps

5. i keep trying to add 2 but then it just continues on.

6. Originally Posted by Chaosreborn
i keep trying to add 2 but then it just continues on.
What are you trying to add two to? you don't have a variable "x" as nadroj describes that keeps track of the previous number of stars.

You can either add such a variable, or find an algorithm that does not depend on that. For example, you can figure out the number of stars as a function of the row.

Also, use descriptive variable names. Especially if you are going to ask for help on an online forum. r,s, and spl are not good names for variables.

7. ok im sorry but the variables are: r = rows, s = stars, and spl = stars per line.