1__Questions_Structures_12

# 1__Questions_Structures_12 - invalid, explain the error. a).

This preview shows pages 1–3. Sign up to view the full content.

CIS 15BG Questions Chapter 12 STRUCTURES 1. NOTE: Questions 1 to 8 are related. First give the graphic representation of the structures describe below. The first structure consists of two fields. The first field is qty (for quantity, an integer), and the second field is book (of type BOOK ). The name of the type is to be BOOK_ORDER . The BOOK structure has four fields: title (string of size 51), author (string of size 81), price (float), and year (integer). 2. NOTE: Questions 1 to 8 are related. Define a type for each of the structures described above. 3. Define order , a variable of type BOOK_ORDER , then initialize it. Let’s say an instructor wants to order 40 books: Beginning with C by Ron House, 59.99, 1994. 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CIS 15BG Questions Chapter 12 STRUCTURES 4. Write a function that receives a structure of type BOOK_ORDER and prints its’ fields to the screen. 5. Assume order is variable of type BOOK_ORDER and ptrOrder is a pointer to order . Determine which of the following statements are valid and which are invalid. If
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: invalid, explain the error. a). printf(&quot;%d&quot;, qty ); b). printf(&quot;%d&quot;, order.qty ); c). printf(&quot;%d&quot;, order-&gt;qty ); d). printf(&quot;%s&quot;, *ptrOrder ); e). printf(&quot;%d&quot;, (*ptrOrder).qty ); f). printf(&quot;%d&quot;, *ptrOrder.qty ); g). printf(&quot;%d&quot;, ptrOrder.qty ); h). printf(&quot;%d&quot;, ptrOrder-&gt;qty ); 2 CIS 15BG Questions Chapter 12 STRUCTURES 6. The exhange function does not work properly. Its task is to exchange (or swap) two variables of type BOOK_ORDER Make all necessary correction. void exchange ( BOOK_ORDER b1, BOOK_ORDER b2 ) { BOOK_ORDER hold; hold = b1; b1 = b2; b2 = b1; return; } 7. Use the exhange function (defined and corrected above) to un-sort a list of books. The function must use a random number: generate a random number in the range 0 to size 1, and then exchange the current book with the book in the random position. void unSort ( BOOK_ORDER list, int size ) { return; } 3...
View Full Document

## 1__Questions_Structures_12 - invalid, explain the error. a).

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online