没有合适的资源?快使用搜索试试~ 我知道了~
系统级编程作业LAB1
4星 · 超过85%的资源 15 下载量 153 浏览量
2012-12-10
23:33:38
上传
评论
收藏 2.09MB DOC 举报
温馨提示
试读
13页
系统级编程作业LAB1We now describe how to create an empty Visual C++ workspace. We then create an empty project within that workspace, and, finally, we create a
资源推荐
资源详情
资源评论
System Level Programming Lab
C++ fundamentals and Type conversion
Student ID _1043111257__
Student Name _郑雪娅______(红色部分为答案)
Start Time ________________________
Finish Time ________________________
1. Objectives:
To write simple C++ programs covering:
Understand how a character is stored in memory;
Understand how an integer is stored in memory;
Understand array and pointer; and
Perform conversion from eight bits (character) to eight bytes to be displayed on
screen.
2. Type and Format in memory – character, integer, short and float
2.1
This exercise is to determine the memory size of different type.
lab1_1.cpp
//Determine the memory size of declaration and variable type
#include <iostream.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
char c;
char s[128];
short i;
short n[64];
printf("%3d %3d", sizeof(c), sizeof(char));
printf("%3d %3d", sizeof(s), sizeof(char[128]));
printf("%3d %3d", sizeof(i), sizeof(short));
printf("%3d %3d", sizeof(n), sizeof(short[64]));
}
The display is:
Now execute the above program and fill in the following:
2021/8/6 - -
1
System Level Programming Lab
#include <iostream.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
char a;
short i;
short s[32];
char c[64];
printf("%3d %3d\n", sizeof(i),8* sizeof(i));
printf("%3d %3d\n", sizeof(a), 8*sizeof(a));
printf("%3d %3d\n", sizeof(s), 8*sizeof(short[32]));
printf("%3d %3d\n", sizeof(c), 8*sizeof(char[64]));
}
2.2
Use the approach of the above, determine the memory size of integer, float, integer[128],
float[16] (lab1_2.cpp)
Write a program to verify your answer and fill in the following: [hint, use sizeof(…) ]
Write down your codes below:
#include <iostream.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
int i;
int in[128];
float f;
float fl[16];
printf("%3d %3d\n", sizeof(i), 8* sizeof(int));
printf("%3d %3d\n", sizeof(f), 8* sizeof(float));
printf("%3d %3d\n", sizeof(in), 8* sizeof(int[128]));
2021/8/6 - -
2
System Level Programming Lab
printf("%3d %3d\n", sizeof(fl), 8* sizeof(float[16]));
}
Write down your expression amongst the difference in size between character, integer, float,
short, char[8], int[8], short[8], float[8]
character 1byte 8bit char[8] 8byte 64bit
integer 4byte 32bit int[8] 32byte 256bit
float 4byte 32bit float[8] 32byte 256bit
short 2byte 16bit short[8] 16byte 128bit
2.3
This exercise is to display the decimal and octal values so that you know how it is stored in
memory.
lab1_3.cpp
//Determine the memory size of declaration and variable type
#include <iostream.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
for (char i = 30; i <41; ++i)
printf("i: dec=%d oct=%o \n", i, i);
}
the output is:
2021/8/6 - -
3
剩余12页未读,继续阅读
资源评论
- human0002013-05-07可以吧,但是内容不全,有些作业没有
wuwaao
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 智能主板原理图,文件后缀是SCHDOC
- 计算机网络期末复习是一个综合性的过程,需要对网络的基础理论、协议、体系结构以及应用等有深入的了解 以下是一些建议的复习内容和方法
- Playwright+Python自动化测试
- 现成版动图爱心exe文件直接用window打开即可展现
- 零基础DSP实战TMS320F28035:第十节,DSP之CLA内核应用实战.zip
- 789654645645
- 当你说到HTML(HyperText Markup Language),它是用于创建网页内容的标准标记语言 HTML通过标签(t
- 基于zigbee和stm32的智能家居系统,上位机使用Qt编写,实现了基本的监控 主要包括监控室内温度、湿度、烟雾浓度等
- 以下是一个简单的HTML5和CSS3代码示例,用于在网页上展示一个爱心形状,并搭配一些文本作为表白使用 这个代码不依赖于Java
- 079版ijl15.dll 源码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功