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;

Source: Internet
Author: User

/*
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.