《实验参考解答》PPT课件.ppt

上传人:牧羊曲112 文档编号:5582426 上传时间:2023-07-30 格式:PPT 页数:15 大小:232KB
返回 下载 相关 举报
《实验参考解答》PPT课件.ppt_第1页
第1页 / 共15页
《实验参考解答》PPT课件.ppt_第2页
第2页 / 共15页
《实验参考解答》PPT课件.ppt_第3页
第3页 / 共15页
《实验参考解答》PPT课件.ppt_第4页
第4页 / 共15页
《实验参考解答》PPT课件.ppt_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《《实验参考解答》PPT课件.ppt》由会员分享,可在线阅读,更多相关《《实验参考解答》PPT课件.ppt(15页珍藏版)》请在三一办公上搜索。

1、实验2参考解答,实验内容 1,编写一个简单的程序验证当前所用系统的各基本数据类型所占存储空间的大小将结果输出在屏幕上,参考代码,#include using namespace std;int main()coutSize of short:sizeof(short)endl;coutSize of unsigned short:sizeof(unsigned short)endl;coutSize of int:sizeof(int)endl;coutSize of unsigned int:sizeof(unsigned int)endl;coutSize of long:sizeof(l

2、ong)endl;coutSize of unsigned long:sizeof(unsigned long)endl;coutSize of float:sizeof(float)endl;coutSize of double:sizeof(double)endl;coutSize of long double:sizeof(long double)endl;int i;coutSize of i:sizeof(i)endl;,实验内容 2,编写一个简单的程序实现简单的柜台操作:从键盘输入当前物品的价格、数量,计算应收金额,从键盘输入顾客所付金额,计算找零,参考代码,#include us

3、ing namespace std;int main()float total;float paid;float change;couttotal;coutpaid;change=paid-total;coutThe change is:endl;coutchangeendl;,程序设计I实验,实验3:简单的程序调试、基本数据类型与操作,实验目的,巩固基本的编程步骤和方法了解简单的程序调试方法练习变量的定义和简单操作掌握字符类型的使用掌握类型转换的规则和用法,编程错误,Syntax error代码存在语法问题编译时出错Runtime error程序不能正常运行无法完成操作,如输入数据类型不对L

4、ogic error程序结果与期望不符,程序调试,查错、纠错的过程程序调试工具输出窗口:程序输出的信息及错误提示信息注意:错误提示的位置未必准确;数量未必一致断点工具Watch工具,输出窗口,代码窗口,状态栏:行号,列号,编译、链接结果,错误提示:文件名(行号):错误信息,“z”这个变量没有声明过“先声明后使用”,实验内容-1,基于下面的代码,编写一个程序并进行编译、运行。观察运行结果并分析类型转换的影响/已知矩形面积为20、长为8,求其宽度。cout Width is:20/8 n;cout Width is:float(20)/8 n;cout Width is:(float)20/8 n;cout Width is:20/float(8)n;cout Width is:20/(float)8 n;cout Width is:float(20/8)n;,实验内容-2,编写一个程序,实现:从键盘读入三个整数,计算其平均值,把结果显示在屏幕上。提示:注意数据类型的选择,实验内容-3,课堂的示例程序自己动手输入、调试、运行,结束!,

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号