Home  >  Article  >  Backend Development  >  C language implements inputting the radius of a circle to calculate the area of ​​the circle

C language implements inputting the radius of a circle to calculate the area of ​​the circle

王林
王林Original
2020-05-11 11:17:4933984browse

C language implements inputting the radius of a circle to calculate the area of ​​the circle

Formula used:

Perimeter formula: C=2πr

Area formula: S=πr²

Specific code:

#include<stdio.h>
int main()
{
    float r,PI;
    PI = 3.14159;
    printf("请输入圆的半径:\n");
    scanf("%f", &r);
    printf("圆的周长为%.7f\n圆的面积为%.7f\n", 2 * PI*r, PI*r*r);
}

Recommended tutorial: c language tutorial

The above is the detailed content of C language implements inputting the radius of a circle to calculate the area of ​​the circle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn