Partial preview of the text
Download Midterm Exam Topics - Introduction to Computer Science I | CS 162 and more Exams Computer Science in PDF only on Docsity!
CS 162: Introduction to Computer Science TT Midterm (700 points) Name; TURN IN ANY SCRATCILPAPER USED WITH YOUR EXAM! CLOSED BOOK,,,CLOSED NOTES! L. Functions and Arguments (25 points) Por each of the following argument dara iypes, write the function prototype. Also, define the variables you would reed to call the fuaction -- and show what the function call would look Hke: Argument Data Type integer by value structure of type person by reference array of structures of type person of size 200 Slructure of type person by value integer by reference array of integers of size 20 anay of characters of size LOO character by vali Function Prototype Variable Definitions . vod tab y int j: wae peesen® void « petton £ d, iat wore PES OM wen th @ void cine a ) rah vn e_ Chee €2 void _ eher character by reference void f(_ chet a Function Calf gervch mame {char fese CYT char mnradle C41I) enar last C4, ) Struct book {char Hele CST) pamme author 5 hand; int nvm. OAs Eloat pria, } . alas bookstore { C book wd oe “Cerae 490 2)) Wad cemote 4 D5 de: priv K ineroeu CSO]: ee $19¢.0f- verter, 45 lookstere tf beokstre 6) { Size -0f nvertory ae ) 3. Implementing C++ (35 paints} 3a. Using the class designed for question Za, implement a member hinction to read a single book’s wtlormution from the user and store it as one ot the 50 books; if the book that has been obtained from the user has the same Cite as one already storcd in the array of g books, don’t add it to the Lsi. -- you do not need te suppiy any prompys, echo your inpar, or provide comments ~ -= ma 8 ah ——— 3b. Now, show tow a client program (the mainy would create an object of this te oootsbre variable 5 3c. Now, show how the client program could call the function defined in 3a: Variable. add C~w)j 3d, Show how the chent would create an array of 7 objects of this class: bookstore chein( Fy 3e. Now, show how the clieot program could call ihe function defined it 3a for the [asi clement of this array: e hain Co 3 ° add Cc yy NoT oN TEST 2 pore pov Stage ) Cpre Struct name wf male; eg last) cher “ 4. a name aks + Cou oo) ; ¢ n. ge cher [ | “fee vent tan) Ai}; authare fst = * ( author. fest temp); gtrepy cin ign (); cout