#include <iostream>
using namespace std;
int main()
{
int i, j, lines;
cout << "This Program creates Christmas Trees." << endl;
do
{
cout << "Please enter a number between 1 and 30" << endl;
cin >> lines;
}while (lines < 1 || lines > 30);
for(j=0; j<lines; j++)
{
for(i=0; i<=j; i++)
{
cout << "*";
}
cout << endl;
}
}
You were really close. :) Just take out the first for loop, and the i=i++ is something you *do not* want to do (think about it).
-Fredric
Daishi
Junior Poster in Training
80 posts since Aug 2005
Reputation Points: 10
Solved Threads: 2
Err', sorry, reread your post more carefully..if you want a christmas tree effect, then you need to include that for loop I said to leave out, but set the initial value of i to j in it, change 40 to lines, and increment i correctly. Then you have to make one little change to the second for loop and you should get a Christmas tree. Ok, no more hints! :)
-Fredric
Daishi
Junior Poster in Training
80 posts since Aug 2005
Reputation Points: 10
Solved Threads: 2
I assume you have the left side of the christmas tree. What you need is the right side? You just need to print out twice as many stars in that case.
0: *
1: ***
2:*****
-Fredric
Daishi
Junior Poster in Training
80 posts since Aug 2005
Reputation Points: 10
Solved Threads: 2