Calculate the area and circumference of a circle

#include <stdio.h>

#define PI 3.141592654
float area(float r); //Declare the function prototype of the computer area
float perimeter(float r); //Declare the function prototype of the computer perimeter

int main()
{
float r; //Save the radius variable
float s, L; //Save the area and circumference of the circle
printf("Please enter the radius of the circle:"); //Display the prompt message
scanf("%f ", &r);
s = area®;
L = perimeter®;
printf("radius R=%.2f,area S=%.2f \n", r, s);
printf("radius R=%.2f, Circumference L=%.2f \n”, L, s);//Output the circumference of the circle

return 0;

}
//
Float area(float r)
{
float s;

s = PI*r*r;
return s;

}
//
Float perimeter(float r) to calculate the perimeter of a circle
{
float l;
l = 2 * PI*r;
return l;

}

Guess you like

Origin blog.csdn.net/smileui/article/details/89893084