(C syntax) Calculate the circumference and area of the circle, and the circumference of the grammar circle

Source: Internet
Author: User

(C syntax) Calculate the circumference and area of the circle, and the circumference of the grammar circle

Knowledge point:

Header file # define usage

Usage of Float % f to control decimals.

 

Content: calculates the circumference and area of the circle.

Input description:

One row, radius value, real type

Output description:

Pi = the perimeter and area in 3.1415 cases (retain 2 decimal places), output in two rows

Input example: if the question is not specified, read the data in multiple groups or refer to a001.

10.0

Output example:

62.83 314.15

 

#include <stdio.h>#define pi 3.1415int main(){ float a; scanf("%f",&a); printf("%.2f\n%.2f\n",2*pi*a,pi*a*a); return 0;}

 


C language for circle perimeter and area

# Include <stdio. h>
# Define PHI 3.14
Void main ()
{
Float cir (float r );
Float area (float r );
Float r, c, s;
Printf ("input r = ");
Scanf ("% f", & r );
C = cir (r );
S = area (r );
Printf ("\ nc = % 5.2f s = % 5.2f", c, s );
}
Float cir (float r)
{Float c;
C = 2 * PHI * r;
Return (c );
}
Float area (float r)
{Float s;
S = PHI * r;
Return (s );
}

Primary C language question: Use two functions to separate the circle perimeter and area

# Include "stdio. h"
# Define Pi 3.1415926
Double zhouchang (double r)
{
Double s;
S = 2 * Pi * r;
Return s;
}
Double mianji (double r)
{
Double s;
S = Pi * r;
Return s;
}
Int main ()
{
Double r, m, n;
Printf ("enter the circle radius :");
Scanf ("% lf", & r );
M = zhouchang (r );
N = mianji (r );
Printf ("the circumference of the circle is % lf, and the area is % lf \ n", m, n );

}




Related Article

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.