手册目录
C 教程
C结构体
C枚举
以下是一个现实生活中的例子,使用不同数据类型来计算和输出多个项目的总成本:
// 创建不同数据类型的变量
int items = 50;
float cost_per_item = 9.99;
float total_cost = items * cost_per_item;
char currency = '$';
// 打印变量
printf("项目数量: %d\n", items);
printf("每个项目的成本:%.2f %c\n", cost_per_item, currency);
printf("总成本 = %.2f %c\n", total_cost, currency);
运行实例 »点击 "运行实例" 按钮查看在线实例
相关视频
科技资讯
24小时阅读榜
1
2
3
4
5
6
7
8
9
10
精品课程
共5课时 | 17.4万人学习
共49课时 | 78.2万人学习
共29课时 | 62.5万人学习
共25课时 | 39.7万人学习
共43课时 | 73.8万人学习