我们在前面已经初步接触了scanf()函数,现在我们看这个程序:
//talkback_bmi.c 使用浮点型变量计算BMI指数
#include <stdio.h>
float square(float n);
#define STANDARD 22 //定义了一个名为STANDARD的常量,即标准BMI
int main()
{
float height, weight, result, bmi;
char name[40];//定义了一个名为name的,可容纳40个字符的数组
printf("请输入你的名字:");
scanf("%s", name);//将用户输入的字符串存储到数组name里
printf("请输入你的身高(以米为单位):");
scanf("%f", &height); // 获取用户的输入
printf("请输入你的体重(以公斤为单位):");
scanf("%f", &weight);
resul