Lecture 3 worksheet



EE319K Lecture Lec13.ppt in class worksheet (last one)

Question 1. List three ways modules are interdependent.

Question 2. A software module has three files. What are these files, and goes in each?

Question 3. Show the memory allocation of a 3-row by 4-column, 16-bit, 2-D array stored in row-major format. Show the same array in column-major format.

Question 4. Show the C code that defines a 3-row by 4-column, 16-bit, 2-D array in RAM.

Question 5. If an array is defined in permanent RAM, what are its initial values?

Question 6. If an array is defined as a local variable, where is it allocated and what are its initial values?

Question 7. What is a struct?

Question 8. What is typedef?

Question 9. When associated with a struct, what does const do? Answer: Interestingly, when you get to EE312, there will be no ROM into which to place software or data, so const actually means, the software cannot change its value at run time.

Question 10. Explain the difference between these two code pieces

|long Data[10][4]; |long Data[10][4]; |

|long *Pt; |long *Pt; |

|void main(void){ long n; |void main(void){ long n; |

|Pt = Data; |Pt = &Data[0][0]; |

|n = Pt[4][5]; |n = Pt[4][5]; |

Question 11.

Part a) Show the C code to define a structure with one char called A, one short called B, and one long called C. Include a typedef so the structure is called Stuff.

Part b) Show the C code to define two objects of type Stuff called S and T, and a pointer to an object of type Stuff called P.

Part c) Show the C code that sets the A field of T to -1, and the B field of S to 5.

Part d) Show the C code that makes P point to S. Using the pointer, make the B field of S to 5.

Part e) Show the C code to define an array of ten objects of type Stuff called U.

Part f) Show the C code the sets all of the A fields of U to -1, all of the B fields of U to 5.

Part g) Show the C function that takes a call by reference parameter to an object of type Stuff and the sets the A field to -1, and the B field to 5.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download