《HelloWorld程序库存清单应用程序》由会员分享,可在线阅读,更多相关《HelloWorld程序库存清单应用程序(12页珍藏版)》请在金锄头文库上搜索。
1、HelloWorld程序库存清单应用程序 C 程序概览输入 输出数据类型与变量算术运算 HelloWorld程序说明 2006 09 11 includeusingnamespacestd intmain cout HelloWorld endl return0 注释 2006 09 11单行注释多行注释 2006 09 11changetheinterface 程序进行人机交流的同时 也用于人际交流 注释的作用就是为了让别人更容易的读懂程序编译时 编译器忽略注释 预处理命令 includeusingnamespacestd 引入库函数使用标准名空间 main函数 intmain cout H
2、elloWorld endl return0 语句 cout HelloWorld endl 像标准输出设备输出内容return0 返回特定的值到调用点 库存清单应用程序 2006 09 12 includeusingnamespacestd intmain intcartons intitems intresult cout cartons cout items result cartons items cout n共有 result endl return0 变量声明 intcartons intitems intresult 命名规则类型 数据类型 从标准输入设备输入 cin cartons cin items 读入由键盘输入的值 存储读入的值 变量在内存中的形式 变量对应于内存中的一块存储空间这个存储空间中记录的数值 对应的是变量的值 算术运算 result cartons items 高级语言中的算术运算和代数中的算术运算的形式基本上一样 C 中的算术运算 加法 减法 乘法 除法 求余或取模