1__Questions_Structures_12

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Background image of page 3
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("%d", qty ); b). printf("%d", order.qty ); c). printf("%d", order->qty ); d). printf("%s", *ptrOrder ); e). printf("%d", (*ptrOrder).qty ); f). printf("%d", *ptrOrder.qty ); g). printf("%d", ptrOrder.qty ); h). printf("%d", ptrOrder->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

Page1 / 3

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 Right Arrow Icon
Ask a homework question - tutors are online