第二章优秀实验报告.doc

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第二章优秀实验报告

西安交通大学实验报告 课 程 计算机程序设计 实 验 名 称 C++程序设计 第1页 共9页 系 别 材料科学与工程 实 验 日 期 2014年09月 19日 专业班级 材料22 组别____ 实验报告日期 2014 年09月19日 姓 名 许自宽 学号 2120201043 报告退发 ( 订正 、 重做 ) 同 组 人_______________ 教 师 审 批 签 字 实验目的 (1) (2)A.首先要输出表2-1中的类型说明符;然后用“sizeof()“计算该类型占的字节数n;然后输出n;接下来的其他类型都这样做。 B.创建不同类型的变量,并且给他们赋值,然后用“sizeof()”函数计算该变量所占的字节数,并赋值给n,然后输出n; C.直接用“sizeof()”函数计算给出的常量所占用的字节数,并赋值给n,然后输出n。 程序源代码: #includeiostream //包含基本输入输出的库头文件 using namespace std; //使用名字空间 int main() //主函数 { cout-----------未赋值-----------endl; int n; //说明用n表示整数 n=sizeof(short int);//计算类型大小,将所占字节数赋值给符号n coutshort int在内存中占的字节数为: nendl;//显示 n=sizeof(int); //整形 coutint在内存中占的字节数为: nendl; n=sizeof(long int); //长整形 coutlong int在内存中占的字节数为: nendl; n=sizeof(char); //字符串 coutchar在内存中占的字节数为: nendl; n=sizeof(bool); //逻辑性 coutbool在内存中占的字节数为: nendl; n=sizeof(float); //浮点型 coutfloat在内存中占的字节数为: nendl; n=sizeof(double); //双精度型 coutdouble在内存中占的字节数为: nendl; cout-----------赋值-----------endl; short int a=12; int b=12; long int c=12; char d=d; bool e=true; float f=1.2F; double g=1.2; n=sizeof(a);//计算类型大小,将所占字节数赋值给符号n coutshort int在内存中占的字节数为: nendl;//显示 n=sizeof(b); //整形 coutint在内存中占的字节数为: nendl; n=sizeof(c); //长整形 coutlong int在内存中占的字节数为: nendl; n=sizeof(d); //字符串 coutchar在内存中占的字节数为: nendl; n=sizeof(e); //逻辑性 coutbool在内存中占的字节数为: nendl; n=sizeof(f); //浮点型 coutfloat在内存中占的字节数为: nendl; n=sizeof(g); //双精度型 coutdouble在内存中占的字节数为: nendl; cout------常数所占的字节大小------endl; n=sizeof(3);//计算常数所占字节大小,将所占字节数赋值给符号n cout3在内存中占的字节数为:nendl;//显示 n=sizeof(3.0); cout3.0在内存中占的字节数为: nendl; n=sizeof(1.0E-4); cout1.0E-4在内存中占的字节数为: nendl; n=sizeof(e); coute在内存中占的字节数为: nendl; n=sizeof(continue); coutcontinue在内存中占的字节数为:nendl; n=sizeof(true); couttrue在内存中占的字节数为: nendl; n=sizeof(false); coutfalse在内存中占的字节数为: nendl; return 0; } 结果分析 不

文档评论(0)

dajuhyy + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档