(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 );
}