C Program to find the area of triangle, circle and square using switch case.

0
6
digitalample eye
Write a c program to find the area of triangle.
Write a c program to find the area of circle.
Write a c program to find the area of square.
Write a c program to find area of triangle, circle and square using switch case.
C Program to find the area of triangle, circle and square using switch case.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int choice;
clrscr();
printf("1. For are of triangle");
printf("2. For area of circle");
printf("3. For area of ractangle");
printf("4. For are of square");
printf(" Enter your choice:n");
scanf("%d",choice);
{
case 1:
{
int b,h,a;
printf("Enter base and height:");
scanf("%d%d",&b,&h);
a=(b*h)/2;
printf("The aree of triangle=%d",a);
break;
}
case 2:
{
float r,a;
printf("Enter readius");
scanf("%g",&r);
a=3.14594*r*r;
printf("n area of circle=%g",a);
break;
}
case 3:
{
int l,b,a;
printf("Enter lenght and breadth:");
scanf("%d%d",&l, &b);
a=l*b;
printf("Area of rectangle:%dn",a);
break;
}
case 4:
{
int a,b;
printf("Enter lenght");
scanf("%d",&a);
b=a*a;
printf("The are of square:%d",b);
break;
}
default:
{
printf("Wrong Choice");
}
getch();
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here