C 编程:从基础到实践
1. 矩形计算程序示例
下面是一个用于计算矩形周长、面积和体积的程序代码:
#include <stdio.h>
void perimeter(float l, float w)
{
printf("\nPerimeter is %.2f\n", (2*l) + (2*w));
}
void area(float l, float w)
{
printf("\nArea is %.2f\n", l * w);
}
void volume(float l, float w, float h)
{
printf("\nThe volume is %.2f\n", l * w * h);
}
main()
{
int selection = 0;
float l,w,h;
printf("\nThe Function Wizard\n");
printf("\n1\tDetermine perimeter of a rectangle\n");
printf("2\tDetermine area of a rectangle\n");
printf("3\tDetermine volume of rectangle\n");
printf("\nEnter selection: ");
scanf("%d", &selection);
switch (selection) {
case 1:
printf("\nEnter length: ");
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



