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?
# include<iostream>
# include<conio.h>
usingnamespace 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;
}