Homework 1 Information, ECS50 Spring 2000
- Homework due by Midnight on Monday, April 10
- Do all problems.
Assignment:
(1) Do Problem 1.2 with the following numbers:
27, 87365, 19, 2049, 255, 128, 65535
(2) Problem 1.3
(3) Do Problem 1.4 with the following numbers: (0x = base 16, 0o = base 8)
0xB319, 0xFD83, 0x1A53, 0x3EC6
0o6732, 0o1234, 0o7074, 0o4635
(4) Do Problem 1.5 with the following binary numbers:
0 1 0 1 1 1 1 1 0 0 1 1
0 0 1 0 1 1 0 0 1 0 0 0 1
1 0 1 1 0 1 1 0 1 1 1 1 0 0 0 0
1 0 0 1 0 1 0 0 1 0 1 1 1 0 1 0
0 0 1 1 1 1 1 1 0 0 1 0 1 0 1 1
(5) Do Problem 1.6 with the following numbers:
-77, 1151, 452, -20413, -3, 40
(6) Do Problem 1.7 with the following hex numbers:
FDA0, 1923, D3A8, 76AC, 39B3, 80A2
(7) Do Problem 1.8 assuming a 13-bit word size.
(8) Do Problem 1.9 (a) with the following patterns:
$5468697320636C61737320697320677265617421
$54686579277665206B696C6C6564204B656E6E7921
Do Problem 1.9 (b) with the following strings:
"You ROCK!
"Here Today ..."
"What's Happening?"
(9) Do Problem 1.11 (a) with the following numbers:
$85730C, $89E248
Do Problem 1.11 (b) with the following numbers:
75.25, -34.625
10: Program: This is a small C program to further explore data conversion as
well as to shake the rust off your programming skills.
1. Implement the C library function atoi().
int my_atoi(char *str);
This function takes a string of digits as its argument and returns the integer
it represents. The number begins with a digit (or a '-' for negative numbers)
and is finished at the end of the string or at any non-numeric character.
Don't worry about NULL strings or overflow. (The C library doesn't, so why
should you?)
Examples:
atoi("23") returns 23
atoi("-2") returns -2
atoi("112abc") returns 112
atoi("hello?") returns 0