Can someone help me to create a syntax for a christmas tree... (the christmas tree must be like the shape of a true to life one) thanks.

What have you tried? We're not going to give anything away unless you put forth some effort first.

What have you tried? We're not going to give anything away unless you put forth some effort first.

i used case switch...
for my loop...

case1:{ for(x=1;x<=5;x++)
          for(y=1;y<=x;y++)
          gotoxy(20,4);
          printf('*\t");
          printf("\n\n");

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

Welcome to the forum, Wurdig! ;)

Remove the switch case. It just makes things more difficult.

You'll need two nested for loops. The outer one will range from 0 to < MaxRows. The inner for loop is for the columns in one row, and will range from 0 to < MaxCols.

One or two if statements inside the inner for loop, will give the logic needed to either print a char (putchar('*'), or print a blank char (putchar(' ').

It's very helpful to see the logical steps needed, if you do it several times by hand, with tree's of different sizes, with paper and pencil first. Keep your code as simple as possible. Simple is good!

Edited 5 Years Ago by Adak: n/a

This question has already been answered. Start a new discussion instead.