The code you all provided was useful in determining the end result. However, the mistake of the triangle's actual apperance was MINE.
This is what it's supposed to look like:
I wonder...when I type up the spaces and asterisks, does the triangles still appear slanted? Anyhow, this is the code I used:
I can get the desired triangle when my base is 7. How can I get it to work with bases such as 9 and 11, etc...
Due: October 11, 2004
This program is called the Christmas Tree because it takes on the shape
of a tree (triangle) and its height depends largely on the base the user inputs*/
int base, currentrow, spaces, counter; //my necessary local variables - currentrow could also be the height
printf("Please enter the base: "); //input prompt
scanf("%d", &base); //the value for the base is stored for later manipulation
for(currentrow=1; currentrow<base; currentrow++) //my first for loop
for(spaces=0; spaces<base-currentrow; spaces++) //without this, the triangle would be slanted
for(counter=0; counter<(2*currentrow-1)-4; counter++) //this prints the stars
The base always has to be an odd integer (as I had already clarified, I believe) and the height of the triangle is half of the base and plus one. h=(b/2)+1 for those visual learners.
If that's the only thing I have to implement, then could someone tell me how to? And what I mean by that is, where do I put it? Thanks.