77 956
Assignments Done
98,4%
Successfully Done
In August 2019

Answer to Question #44119 in C++ for Steve

Question #44119
Provide the definition for each of the following structures:



a) Structure Inventory, containing array of characters partName[ 30 ], integer partNumber, and floating-point price.

b) A structure called Address that contains character arrays street[25], city[20], country[30].

c) Structure Student, containing arrays firstName[ 15 ] and lastName[ 15 ] and homeAddress of type Address ( part (b)).



Given the following structure:



struct book {

char title[50];

char auther[50];

float price;

};



book b1 = {"introduction to fortran", "ali hassan", 98.0};

book b2 = {"introduction to lisp", "ahmad hassan", 98.0};

book b3;

book *b;



If there is no errors, what will be the output produced by the following code segments? If there is errors, identify and fix

them. First do it in your head and then try out.



1) b3 = b1;

cout << b3.title << endl;



2) b3 = b2;

if (b3 == b2)

cout << b3.title << " == " << b2.title << endl;

else

cout << b3.title << " != " << b2.title << endl;



3) b = &b1;

if ((*b).title == b1.title) {

cout << "It is the same book " << endl;

}



4) b = &b2;

if (b->price == b1.price)

cout << b->title << " has same price as " << b1.title;

else

cout << b->title << " has different price as " << b1.title;



5) b3.title = b1.title;

cout << "b1 and b3 have the same title " << endl;



6) b = &b2;

b -> price = 100;

cout << b1.price << endl;



7) b = &b2;

if (strcmp(b1.author, b->author) )

cout << "b1 and b2 having the same author " << endl;



8) if (b1.price > b2.price)

cout << b1.title;

else

cout << b2.title;



9) Write a code segment that prompt the user to enter the number of books to be entered from keyboard.



10) Dynamically declare an array of books with size as entered by the user in 8



11) Read in and fill the array of books



12) Write a function that takes the array of books and return through parameters the book that has lowest price and the

book that has the highest price



13) Write a function that takes the array of books and reduces the price of each book by 10%.



14) Write a function that takes one parameter author name and displays all books that he wrote and their prices.
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions