主页
C++
C++ 数据类型示例
demo_data_types_reallife
运行 ❯
×
更改方向
保存代码
更改主题
#include
using namespace std; int main() { // Create variables of different data types int items = 50; double cost_per_item = 9.99; double total_cost = items * cost_per_item; char currency = '$'; // Print variables cout << "Number of items: " << items << "\n"; cout << "Cost per item: " << cost_per_item << currency << "\n"; cout << "Total cost = " << total_cost << currency << "\n"; return 0; }
Number of items: 50
Cost per item: 9.99$
Total cost = 499.5$