I am new to C++ and have a problem in a class I am taking.I am having trouble trying to create this the way my professor wants. this is what is required from the program:
Write a complete program that prints out a “tree” of asterisks with the number of lines specified by the user.
The following output is a five-line tree:
1 *
2 ***
3 *****
4 *******
5 *********
I have this as the loop;
for (i = 1; i <= lines; i++)
{
for (l = 1;l <= i; l++) // prints line number
cout <<l;
for(j = 1; j <= i; j++) // calculation to print start
cout <<"*";
cout<<endl;
}
It prints this
1
2
3
4
5
*
1
2
3
4
5
**
etc.. My question is can some one point me in the direction to get the loop to output like the first example.
Thanks