知识库

C语言开发示例:07. 数据输入

2025-02-01 20:03:43 李腾 1 次阅读

area.c

#include <stdio.h>

#define PI 3.14159f

int main()
{
    float radius = 0.0f;
    float diameter = 0.0f;
    float circumference = 0.0f;
    float area = 0.0f;
    const float Pi = 3.14159f;

    printf("Input the diameter of the table:");
    scanf("%f", &diameter);

    radius = diameter / 2.0f;
    circumference = 2.0f * PI * radius;
    area = PI * radius * radius;

    printf("\nThe circumference is %.2f", circumference);
    printf("\nThe area is %.2f\n", area);
    return 0;
}
转载请注明转自www.hylab.cn,原文地址:C语言开发示例:07. 数据输入

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!