Trouble with loops

Im new to programming and is trying to make a program that makes triangles and ask for input several times and ends with when 0 is input.
i have made the code for the triangle with a for loop but cant get it to work with an do while loop so that it can write more triangles.

here is how my code is now

#include<iostream>
#include<conio.h>
using namespace std;
int main( )
{
int i,j,tall;

do
{

cout<<" ange antal steg avsluta med 0: ";
cin>>tall;


for (i=1;j<=tall;++i)
{
for (j=1;j<=i;++j)
{
cout<<"* ";
}

cout<<"\n";
}

}

while ( tall!= 0);


return 0;
}


it repeats as i should and ends when 0 is input but it wont print the triangle hints and tips on how to make it work?
Code tags would make it easier to comment.
1
2
3
int i;
int j = 1;
if ( j <= i ) ...

Undefined result. The value of i has not been set anywhere.
closed account (28poGNh0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# include<iostream>
# include<conio.h>
using namespace std;

int main( )
{
    int i,j,tall;

    do
    {
        cout << " ange antal steg avsluta med 0: ";
        cin >> tall;

        for (i=1;i<=tall;++i)//I think you want to put "i" instead of "j"
        {
            for (j=1;j<=i;++j)
            {
                cout<<"* ";
            }

            cout << "\n";
        }

    }while(tall != 0);

    return 0;
}
thank you so much that fixed it i was almost staring myself blind at something right under my nose :)
Topic archived. No new replies allowed.