/*
2. Use the three functions to calculate the triangle, square, and circular area respectively.
Input); in the main function, you can choose to call them separately;
*/
# Include <stdio. h>
# Define P 3.14
Double Sanjiao (double Di, double Gao)
{
Double mianji = (di * Gao)/2;
Return mianji;
}
Double zhengfangxing (double Bian)
{
Double mianji2 = Bian * Bian;
Return mianji2;
}
Double yuanxing (Double R)
{
Double mianji3 = p * r * R;
Return mianji3;
}
Void main ()
{
Int shuru;
Double shuju1, shuju2, shuju3, shuju4, jieguo;
Printf ("Enter the number code to obtain the area of the image you choose. (1. Triangle. 2. Square. 3. Circle): \ n ");
Scanf ("% d", & shuru );
Switch (shuru)
{
Case 1:
Printf ("low and high input triangles (separated by commas) \ n ");
Scanf ("% lf, % lf", & shuju1, & shuju2 );
Jieguo = Sanjiao (shuju1, shuju2 );
Printf ("Area: %. 2lf \ n", jieguo );
Break;
Case 2:
Printf ("length of the side of the input square: \ n ");
Scanf ("% lf", & shuju3 );
Jieguo = zhengfangxing (shuju3 );
Printf ("area %. 2lf \ n", jieguo );
Break;
Case 3:
Printf ("input circle radius: \ n ");
Scanf ("% lf", & shuju4 );
Jieguo = yuanxing (shuju4 );
Printf ("area %. 2lf \ n", jieguo );
Break;
}
}
Use the three functions to calculate the triangle, square, and circular area respectively (all bottom height radius are input by the user). In the main function, use different options for different calls;