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");

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.