主页
C 语言
C 数据类型示例
demo_data_types_reallife
运行 ❯
×
更改方向
保存代码
更改主题
#include
int main() { // Create variables of different data types int items = 50; float cost_per_item = 9.99; float total_cost = items * cost_per_item; char currency = '$'; // Print variables printf("Number of items: %d\n", items); printf("Cost per item: %.2f %c\n", cost_per_item, currency); printf("Total cost = %.2f %c\n", total_cost, currency); return 0; }
Number of items: 50
Cost per item: 9.99 $
Total cost = 499.50 $