10. Consider the choice is input through keyboard. If choice is 1 then find area of triangle. If choice is 3 then find area of rectangle. If choice is 7 then find area of Square. Otherwise find area of circle

Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1
#include<stdio.h>
int main()
{
	int i;
	float base,height,area,width,length,area1,side,area2,radius,area3;
	scanf("%d",&i);
	switch(i)
	{
		case 1:
	printf("Enter Base:");
			scanf("%f",&base);
			printf("Enter Height");
			scanf("%f",&height);
			area=0.5*base*height;
			printf("Area of Triangle=%f\n",area);
			break;
		case 3:
			printf("Enter Width:");
				scanf("%f",&width);
				printf("Enter Length:");
				scanf("%f",&length);
				area1=width*length;
				printf("Area of rectangle=%f\n",area1);
				break;
	    case 7:
                printf("Enter Side:");
				scanf("%f",&side);
				area2=side*side;
				printf("Area of Square=%f\n",area2);
			break;
default:
			printf("Enter radius:");
			scanf("%f",&radius);
			area3=3.14*radius*radius;
			printf("Area of Circle=%f\n",area3);
		}
	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s