QUESTION #2
1. Write optimized C programs that will do the following:
a. Convert a base 16 number to its base 10 equivalent. Use 23DA as a test number.
b. Convert a base 8 number to its decimal equivalent. Use 7025 as a test number
c. How many integers from 1 to 1000 are not divisible by 8 or 12?
d. How many integers from 1 to 1000 are divisible by 6 or 8?
2. Explain why did you optimize your code this way.
QUESTION #3
1. Considering compacting memory while managing equal-sized blocks. Assume each block consists of a data field and a pointer field, and that we have marked every block currently in use. The blocks are currently located between memory locations a and b. We wish to relocate all active blocks so that they occupy contiguous memory starting at a. In relocating a block remember that the pointer field of any block pointing to the relocated block must be updated. Design an optimized C program for compacting the blocks.
QUESTION #4
1. Write a program in C to multiply two linear matrices. This program should take as input the dimensions of each matrix, as well as the components of each matrix. Remember to write the most optimal code possible. Use the following matrices as a test:
1 0
-2 3 0 6 1
5 4 3 8 -2
0 1
QUESTION #5
1. Assume that your CPU does not have multiply and divide units. You can not use function in C that will not use multiply, divide and modulo operators. Write the following programs:
a) multiply any given number by 7
b) divide any given number by 7
2. Make sure that you write the most optimized code, and give full description of any potential errors that can happen using your function.