Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Manage Menu Driven Program using switch statement

#include<stdio.h>
#include<conio.h>
void main () {
	int ch,r,l,w,b,h;
	float area;
	clrscr();
	printf("enter 1 for area of circle
");
	printf("enter 2 for area of rectangal
");
	printf("enter 3 for area of triagle
");
	printf("enter your choise
");
	scanf("%d",&ch);
	switch(ch) {
		case 1:
		                 printf("enter radious of circle
");
		scanf("%d",&r);
		area=3.14*r*r;
		break;
		case 2:
		                  printf("enter lanth and width
");
		scanf("%d%d",&l,&w);
		area=l*w;
		break;
		case 3:
		                  printf("enter the base and hight
");
		scanf("%d%d",&b,&h);
		area=.5*b*h;
		break;
	}
	printf("area is=%f",area);
	getch();
}
Source by scanftree.com #
 
PREVIOUS NEXT
Tagged: #Manage #Menu #Driven #Program #switch #statement
ADD COMMENT
Topic
Name
7+3 =