Code:
#include<stdio.h>
void main()
{
char choice;
int month,sum,num,i,a,b;
int age,kasarian;
char ans;
int e,c,d;
int num1,num2,diff,prod;
clrscr();
main_menu:
{
printf(" ++++++MAIN_MENU+++++\n");
printf(" + [1] if +\n");
printf(" + [2] switch +\n");
printf(" + [3] for loop +\n");
printf(" + [4] exit +\n");
printf(" ++++++++++++++++++++\n");
printf("enter your choice:");
scanf("%d",&choice);
clrscr();
if(choice=='1')
{
if_program:
printf(" *#*#*#*#*#*#*#*#*#*#*#*#*\n");
printf(" * [A] age *\n");
printf(" * [B] mdas *\n");
printf(" *#*#*#*#*#*#*#*#*#*#*#*#*\n");
printf("Enter Your choice:");
scanf("%s",&choice);
if((choice=='A')||(choice=='a'))
{
printf("enter your age:\n");}
scanf("%d",&age);
if(age>=0 && age<=2)
{printf("still a baby",age);}
else if(age>=3 && age<=12)
{ printf("children",age);}
else if(age>=13 && age<=17)
{ printf("teenager",age);}
else if(age>=18 && age<=26)
{printf("young adult",age);}
else if(age>=27 && age<=39)
{ printf("middle age",age); }
else if(age>=40 && age<=79)
{printf("grand parents",age);}
else
{printf("higher",age);}
printf("do u want to run another if_program?'Y'/'N'");
scanf("%s",&ans);
if((ans=='Y')||(ans=='y'))
{goto if_program;}
}
}
if(choice=='B')
{
printf(" !!!!!!!!!!!!!!!!!!!!!!!!\n");
printf(" !! [1] addition !!\n");
printf(" !! [2] subtraction !!\n");
printf(" !! [3] multiplication !!\n");
printf(" !!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("enter your choice:");
scanf("%d",&choice);
if(choice==1)
{
printf("addition");
printf("enter the first number:");
scanf("%d",&num1);
printf("enter the second number:");
scanf("%d",&num2);
sum = num1 + num2;
printf("The sum of two numbers is:%d",sum);
}
else if(choice==2)
{
printf("subtraction:");
printf("enter the first number:");
scanf("%d",&num1);
printf("enter the second number");
scanf("%d",&num2);
diff= num1 - num2;
printf("the difference of two numbers is:%d",diff);
}
else
{
printf("multiplication");
printf("enter the first number");
scanf("%d",&num1);
printf("enter the second number");
scanf("%d",&num2);
prod=num1 * num2;
printf("the product of two numbers is:%d",prod);
}
printf("GO BACK TO MAIN MENU?'Y'/'N'");
scanf("i",&ans);
if((ans=='Y')||(ans=='y'))
{goto main_menu;}
}
}
if(choice=='2')
{
switch_program:
printf(" #####################\n");
printf(" ## [W] kasarian ##\n");
printf(" ## [Z] animals ##\n");
printf(" #####################\n");
printf("enter your choice");
scanf("%s",&choice);
switch(choice);
if(choice=='W')
{
printf("ienter ang iyong kasarian:");
scanf("%s",&kasarian);
switch(kasarian)
{
case 'a' : case 'A':
{
printf("ikaw ay BABAE");
break;}
case 'b' : case 'B':
{
printf("ikaw ay LALAKI");
break;}
case 'c': case 'C':
{
printf("sa kang BAKLA");
break;}
case 'd': case 'D':
{
printf("TOMBOY ka pre");
break;}
default:
{
printf("invalid:");
printf("do yOU want to run another switch program:?'Y'/'N'");
scanf("%s",&ans);
if((ans=='Y')||(ans=='y'))
{goto switch_program;}
}
}
else if(choice=='Z')
{
printf(" $$$$$$$$$$$$$$$$$$$$\n");
printf(" $$ [1] dog $$\n");
printf(" $$ [2] cat $$\n");
printf(" $$ [3] mouse $$\n");
printf(" $$$$$$$$$$$$$$$$$$$$\n");
scanf("%s",&choice);
switch(choice);
{
case 1:
{printf("the dog is the biggest");
break;}
case 2:
{printf("the cat is the medium");
break;}
case 3:
{printf("the mouse is the smallest");
printf("do you want to run another program?'Y'/'N'");
scanf("s",ans);
if((ans=='Y') || (ans=='y'))
{goto main_menu;}
}
}
}
}
if(choice=='3')
{ loop_program:
printf(" ::::::::::::::::::::\n");
printf(" ::: [E] sum :::\n");
printf(" ::: [F] :::\n");
printf(" ::::::::::::::::::::\n");
printf("enter your choice");
scanf("s",&choice);
if (choice=='E')
{
for(e=1;e<=1;e++)
{printf("$");
printf("\n");
for(c=1;c<=2;c++)
printf("$");
printf("\n");
for(d=1;d<=3;d++);
}
}
else
{printf("invalid choice");}
}
getch();
}
Comment