#include
int main() { age = 15; height = 162; weight = 82.5; isfat = 'y'; printf("年龄:%d 岁\n", int age); printf("身高:%d CM\n", int height); printf("体重:%f KG\n", double weight); printf("是否属于肥胖儿童:%c\n", char isfat); /*%d,%f,%c此类符号在后面会有讲解*/ return 0; } 哪里不对呢!
声明变量应该先声明数据类型,所以数据类型应该加在变量名前,而不是输出的时候再来声明数据类型。
参考代码
#include <stdio.h> int main() { int age = 15; int height = 162; double weight = 82.5; char isfat = 'y'; printf("年龄:%d 岁\n",age); printf("身高:%d CM\n",height); printf("体重:%f KG\n", weight); printf("是否属于肥胖儿童:%c\n",isfat); /*%d,%f,%c此类符号在后面会有讲解*/ return 0; }