Ws 1
Ws 1
Workshop 01
Objectives:
(1) Reviewing for number systems
(2) Exploring memory of a C program
Recommendations
Part 1: Students do exercises using notebooks
Part 2: Students develop programs, run them, write down their memory structure to
notebooks.
101101111 b
+ 100111011 b
110110001 b
110001101 b
010111101000b
Exercise 4 (2 marks)
c:22936 ‘A’
i:22936 1
l:2293 1000
f:22936 0.5
12.809
d:22936
Complete the code of following program then draw it’s memory structure
(2 marks)
#include <stdio.h>
int n;
double X;
char c1;
int main() {
int m;
short s;
long L;
float y;
printf("Code of main:%u\n", &main);
printf("Variable n, add:%u, memory size: %d\n", &n, sizeof(n));
printf("Variable X, add: %p, memory size: %d\n", &X, sizeof(X));
printf("Variable c1, add: %p, memory size: %d\n", &c1, sizeof(c1));
printf("Variable ma, add: %p, memory size: %d\n", &m, sizeof(m));
printf("Variable L, add: %p, memory size: %d\n", &L, sizeof(L));
printf("Variable y, add: %p, memory size: %d\n", &y, sizeof(y));
getchar();
return 0;
}