In: Computer Science
areaCircle() – should accept the radius of the circle from the
main function, calculate the area, and then print the area of the
circle.
//Program for Calculate area of diffrent type of Shapes
#include<stdio.h>
#include<conio.h>
#define pi 3.14
void areaSquare();
void areaRectangle();
void areaParallelogram();
void areaCircle();
void displayMenu();
void main()
{
clrscr();
displayMenu();
getch();
}
void displayMenu()
{
int key;
do
{
printf("Enter your choice to calculate area of which shape:\n1:Area
of Square\n2:Area of Rectangle\n3:Area of Parallelogram\n4:Area of
Circle\n5:exit")
;
scanf("%d",&key);
switch(key)
{
case 1: areaSquare();
break;
case 2: areaRectangle();
break;
case 3: areaParallelogram();
break;
case 4: areaCircle();
break;
case 5: exit();
default: printf("Enter Correct choice\n");
}
}while(1);
}
void areaSquare()
{
int a;
float area;
printf("Enter side to calculate Area of Square\n");
scanf("%d",&a);
area=a*a;
printf("\nArea of Square is %.2f",area);
return;
}
void areaRectangle()
{
int a,b;
float area;
printf("Enter length, width to calculate Area of
Rectangle\n");
scanf("%d%d",&a,&b);
area=a*b;
printf("\nArea of Rectangle is %.2f",area);
return;
}
void areaParallelogram()
{
int a,b;
float area;
printf("Enter base, height to calculate Area of
Parallelogram\n");
scanf("%d%d",&a,&b);
area = a*b;
printf("\nArea of Parallelogram is %.2f",area);
return;
}
void areaCircle()
{
int a;
float area;
printf("Enter radius to calculate Area of Circle\n");
scanf("%d",&a);
area = pi*a*a;
printf("\nArea of Circle is %f",area);
return;
}