I got some problems with my program here. There are lots of lacking in my code. Hope you can help me with this guys. I'm still a student. Here's the problem:
A program that prints figures of (*):
1. Displays a menu
[1] Figure 1
[2] Figure 2
[3] Figure 3
[4] Figure 4
[5] Figure 5
[6] Figure 6
Enter your choice:_
2. Input for no. of levels to be printed.
3. Use functions for menu and 6 functions for printing the different figures.
Here's my codes:
#include"stdio.h"
int menu();
void fig1(int a);
void main()
{
int choice;
choice=menu();
scanf("%d",&a);
fig1(a);
}
int menu()
{
int choice;
printf("[1] Figure 1\n");
printf("[2] Figure 2\n");
printf("[3] Figure 3\n");
printf("[4] Figure 4\n");
printf("[5] Figure 5\n");
printf("[6] Figure 6\n\n");
printf("Enter your choice:",&a);
scanf("%d",&choice);
return(choice);
}
void fig1(int a)
{
int x,y;
for(x=1;x<=a;x++)
{
for(y=1;y<=x;y++)
printf("*");
printf("\n");
}
getch();
}
MENU OUTPUT:
[1] Figure 1
[2] Figure 2
[3] Figure 3
[4] Figure 4
[5] Figure 5
[6] Figure 6
Enter your choice:_
OUTPUT EVERY FIGURE:
*
* *
* * *
* * * *
Figure 1
* * * *
* * *
* *
*
Figure 2
*
* *
* * *
* * * *
Figure 3
* * * *
* * *
* *
*
Figure 4
*
* *
* * *
* * * *
Figure 5
* * * *
* * *
* *
*
Figure 6
Figure 5 and 6 are Christmas tree structure. I can't seem to find a way how make it a Christmas tree.