{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

CIS 15BG Answers Chapter 12 STRUCTURES NOTE: Questions 1 to 6 are related. Two structures are to be used. 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). 1. Define a type for each of the structures described above. typedef struct { char title[51]; char author[81]; float price; int year; }BOOK_ORDER; typedef struct { int qty; BOOK book; }BOOK_ORDER; 2. 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. BOOK_ORDER order = {40, {"Beginning with C", "Ron House", 59.99, 1994}}; 3. Write a function that receives a structure of type BOOK_ORDER and prints it to the screen. void printOrder ( BOOK_ORDER order ) { printf( "%d\n%s\n%s\n%.2f\n%d\n", order.qty, order.book.title, order.book.author, order.book.price, order.book.year ); return; } 1

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern