Professional Documents
Culture Documents
Nguyenkhactrang HE186034
Nguyenkhactrang HE186034
Part 1
Exercise 1 (2 marks): Convert decimal numbers to binary ones
Decimal 4-bit Binary Decimal 8-bit Binary Decimal 16-bit Binary
Exercise 4 (2 marks)
Show binary formats of 1-byte unsigned numbers: 251 , 163, 117
251: 11111011b
163: 10100011b
117: 01110101b
2- Show binary formats of 2-byte unsigned numbers: 551 , 160, 443
551: 00101001 00101111 b
160: 00000000 10100000 b
443:00000001 10110111 b
3- Show binary formats of 1-byte signed numbers: -51 , -163, -117, 320
−51: 11001101b
−163:10100001b
−117:10001011b
320 : Vượt quá vi phạm 1 byte của số nguyên
4-Show the decimal values of 1-byte unsigned representations: :
01100011 b , 10001111 b , 11001010 b , 01001100 b
01100011 b : 9
10001111 b : 143
11001010 b : 202
01001100 b : 76
Exercise 4
int main() {
//KHAI BAO CAC BIEN
char c = 'C';
int i = 10;
long l = 100;
float f = 0.5f;
double d = 3.14;
// IN RA MAN HINH
printf("Variable c: at addr: %u, value: %c, size: %lu\n", &c, c,
sizeof(c));
printf("Variable i: at addr: %u, value: %d, size: %lu\n", &i, i, sizeof(i));
printf("Variable l: at addr: %u, value: %ld, size: %lu\n", &l, l, sizeof(l));
printf("Variable f: at addr: %u, value: %f, size: %lu\n",&f, f, sizeof(f));
printf("Variable d: at addr: %u, value: %f, size: %lu\n", &d, d,
sizeof(d));
getchar();
return 0;
}