Help

Hi, I am new to C++ and ive been trying to create a program and can't understand what im doing wrong Im trying to output stars on 10 lines and each line increment the stars by 2 until the 6th line where i want to decrease the stars by 2 until it gets to one again. Like a sideways triangle. Help would be much appreciated, Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

int main(){
int i,j;
for (int i=1; i<=5; ++i)
{
        for (j=1; j<=i; j== i+2)
        {
                cout << "*";
        }
        cout << "\n";
}
for (int i = 6; i<=10; --i) {
        for (int j = 1; j<=i; j== i-2)
        {
        cout << "*";
        }
        cout << "\n";
        }
return 0;
}
Hi @duvster614

i do not know if
this outputs your
desired shape but
try this:


for (j=1; j<=i; j== i+2)

should be: for (j=1; j<=i; j= i+2)

for (int j = 1; j<=i; j== i-2)

->for (int j = 1; j<=i; j= i-2)

Topic archived. No new replies allowed.