Code:
double squareCM (double a,double b);
double squareM (double a, double b);
double circleCM (double a);
double circleM (double a);
double triangleCM (double a,double b);
double triangleM (double a, double b);
double a,b;
main()
{
char ch,pa;
while(ch!='0')
{
system("cls");
printf("\n 1 - Rectangle");
printf("\n 2 - Circle");
printf("\n 3 - Triangle");
printf("\n 0 - Exit");
printf("\nPlease enter your choice");
ch=getche();
system("cls");
if(ch=='1')
{
printf("\n 1 - Answer in CM");
printf("\n 2 - Answer in M");
printf("\n 0 - Exit");
printf("\n Please enter your choice");
pa=getche();
system("cls");
if(pa=='1')
{
squareCM(a,b);
}
else if(pa=='2')
{
squareM(a,b);
}
}
else if(ch=='2')
{
printf("\n 1 - Answer in CM");
printf("\n 2 - Answer in M");
printf("\n 0 - Exit");
printf("\n Please enter your choice");
pa=getche();
system("cls");
if(pa=='1')
{
circleCM(a);
}
else if(pa=='2')
{
circleM(a);
}
}
else if(ch=='3')
{
printf("\n 1 - Answer in CM");
printf("\n 2 - Answer in M");
printf("\n 0 - Exit");
printf("\n Please enter your choice");
pa=getche();
system("cls");
if(pa=='1')
{
triangleCM(a,b);
}
else if(pa=='2')
{
triangleM(a,b);
}
}
}
}
double squareCM(double a,double b)
{
int counter,d;
printf("Please enter the amount of shapes you are calculating the area of\n");
scanf("%d",&counter);
for(d=1; d<=counter; d++)
{
printf("Please enter length of rectangle\n");
scanf("%lf",&a);
printf("Please enter width of rectangle\n");
scanf("%lf",&b);
double num;
num=(a*b);
return num;
}
}
double squareM (double a,double b)
{
double num;
num=((a*b)/100);
return num;
int counter,d;
printf("Please enter the amount of shapes you are calculating the area of\n");
scanf("%d",&counter);
for(d=1; d<=counter; d++)
{
printf("Please enter length of rectangle\n");
scanf("%lf",&a);
printf("Please enter width of rectangle\n");
scanf("%lf",&b);
printf("%lf\n",squareM(a,b));
getch();
}
}
double circleCM (double a)
{
double num;
double pi;
num=(pi*a*a);
return num;
int counter,d;
double area;
printf("Please enter the amount of shapes you are calculating the area of\n");
scanf("%d\n",&counter);
for(d=1; d<=counter; d++)
{
printf("Please enter the radius of the circle\n");
scanf("%lf",a);
area = pi*a*a;
printf("The area of the circle is: %lf\n", circleCM(a));
getch();
}
}
double circleM (double a)
{
double num;
double pi;
num=((pi*a*a)/100);
return num;
int counter,d;
double area;
printf("Please enter the amount of shapes you are calculating the area of\n");
scanf("%d\n",&counter);
for(d=1; d<=counter; d++)
{
printf("Please enter the radius of the circle\n");
scanf("%lf",a);
area = ((pi*a*a)/100);
printf("The area of the circle is: %lf\n", circleM(a));
getch();
}
}
double triangleCM (double a, double b)
{
double num;
num=((a*b)*0.5);
return num;
int counter,d;
double area;
printf("Please enter the amount of shapes you are calculating the area of\n");
scanf("%d\n",&counter);
for(d=1; d<=counter; d++)
{
printf("Please enter the base of your triangle\n");
scanf("%lf\n",&a);
printf("Please enter the height of your triangle\n");
scanf("%lf\n", &b);
area=(a*b)*0.5;
printf("The area of the triangle is: %lf\n",triangleCM(a,b));
getch();
}
}
double triangleM (double a, double b)
{
double num;
num=(((a*b)*0.5)/100);
return num;
int counter, d;
double area;
printf("Please enter the amount of shapes you are calculating the area of\n");
scanf("%d\n",&counter);
for(d=1; d<=counter; d++)
{
printf("Please enter the base of your triangle\n");
scanf("%lf",&a);
printf("Please enter the height of your triangle\n");
scanf("%lf", &b);
area=(((a*b)*0.5)/100);
printf("The area of the triangle is: %lf\n",triangleM(a,b));
getch();
}
}