Popular in Course
Popular in Computer Information Technology
This 8 page Class Notes was uploaded by Darrion Bednar on Saturday September 19, 2015. The Class Notes belongs to CISC181 at University of Delaware taught by Staff in Fall. Since its upload, it has received 47 views. For similar materials see /class/207174/cisc181-university-of-delaware in Computer Information Technology at University of Delaware.
Reviews for IntroductiontoComputerScienceII
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/19/15
ZOOQ S CISC 181 01X Nate 7 Yau shbuld be able t0 find the answers t0 these Practice Mid Term A questibns in the Lectures Text 0r Labs 100 Points total If yau are in daubt after making an hanest e brt email me with the questibn in questibn 2 PTS NAME DATE SECTION Advice brie y review the questions amp determine if there are any confusing requirements then answer the questions in the order that makes the most sense to you If something looks like a mistake raise your hand right away don t shout out no right answers to problem 5 When I provide code fragments assume that everything else includes namespace etc is correct In cases where more than one answer is true choose the best answer among the choices Q 01 10 points Answer TrueFalse for the following questions a A C compiler interprets lines of code one at a time as they are executed F b An assembler converts machine language to C or C F c A given struct can hold only one primitive data type F d C functions must directly mention themselves to be recursive F e constantampsorrow is a valid C identifier F 1 C allows function invocations to precede function declarations F g bool floatVal declares a oating point number F h Compiled C programs are guaranteed to produce the same result for every CPU and operating system F i Only b and f are correct F Q 02 4 points Choose the best answer The example of Java virtual machine code shown in the lecture was written mostly in a Java b Commonlisp c OCAML d C e Fortran f C Q 03 4 points putting include ltiostreamgt at the top of a C file does the following a Appeases the idols on Strauss 7 so they will go break someone else s program b Tells the compiler you want to use the programmers namespace c Causes the compiler to output assembly language in a stream rather than a block d Allows you to include the standard math library e Virtually adds thousands of lines of declarations to your code IZI I Gives you access to the standard C library Q 04 4 points What will the following code fragment print given that int X 3 if x ampamp x 0 ampamp 0 cout ltlt quotOKquot ltlt endl else cout ltlt quotNot OKquot ltlt endl OK b Not OK IZI c Nothing 7 taking the address of O crashes the program Page 1 of 6 Points Lost this page QOS 4 points You may find this useful in later questions Fill in the missing binary values for the following table QO6 9 points What will the following code fragments print intx3 inty39 39t 39 a cout ltlt x y ltlt endl 7 b cout ltlt 3 y 55 x a y ltlt endl 0 c cout ltlt false II x ampamp z amp 2 35355le H Y 44ltltend1 Y xgty33 44 QO7 4 points In order to use cout ltlt in a C program without using the scope operator the programmer must a b c d e f g Provide a gtgt cin to balance it Redirect the output to standardamppoors Nothing 7 it just works like magic Include the line include ltiostreamgt Include the line using namespace st a and d d and e M QOS 6 points Given 3 functions int Page 2 of 6 fint fint gint hint x int gint x int hint x x 2 hx 1 ght2 x return xlt 1 x x return x lt 0 f x x return x lt 1 fx f g and h are all recursive not one of f g and h is recursive f and g are recursive but h is not f and h are recursive but g is not g0 and h are recursive but f is not IZI they are all illegal functions in C Points Lost this page Q09 5 points Which of the following problems does the C namespace approach solve a making the language easier to learn b preventing modification of global variables c preventing corruption of local variables d preventing quotcollisionsquot where the same identifier is used in different ways by different modules M e preventing quotsubversionsquot where last include file read removes all previous identifiers Q10 5 points A for statement which has no initialization test or update eXpression a will never terminate b can be terminated by a quotcontinuequot statement c will not be evaluated d can be terminated by a brea or a goto statement IZI e loops just once then stops because of the implicit test Qll 5 points short int x 0 for cout ltlt quotx quot ltlt x ltlt endl Which choice best describes the result of executing this code a The code will print exactly 32768 lines of output b The second line printed will be X 1 M c The last X printed will be 32767 d The first line printed will be X 1 e This code will break because the braces are on the same line as the for Q12 5 points Part A Define a struct named stats that holds an integer named count a double named ave and a double named sd struct stats int count double ave Part B Define a struct named player that holds a character array of size 20 named name and a stats struct named personalStats struct player char name20 stats personalStats Page 3 of 6 Points Lost this page Q13 6 points Consider the code fragments int donna int input bool reset false static int summer 0 if reset summer 0 else summer input return summer H forint i 0 i lt 7 i donna i if4 i donna999 true cerr ltlt quotdonna0gt quot ltlt donna0 ltlt endl When executed this code will 39 a segfault 7 because we called donna with too few arguments b print donna0gt 11 c print donna0gt 1020 d print donna0gt 21 e print donna0gt 0 1 print donnadonnadonna until you run out of paper Q14 6 points Fill in the missing line or lines of the following shuf e function The function is intended to give every element of ar an opportunity to be swapped with some randomly chosen element of the same array Add no more than 43 characters void shuff1eint ar int arLen orint i O i lt arLen i int tmp ari to rand arLen ari arto what goes here arto tmp what goes here Q15 6 points Write a function displayRowint row int len Which displays a character for each integer in row If the integer is gt 0 display C if it is lt 0 display N Do not use an if statement or a switch statement in this function 3 pts if you do so void displayRowint row int len for int i 0 i lt len i cout ltlt rowi gt 0 C N cout ltlt endl Page 4 of 6 Points Lost this page Q16 5 points Yossarian a neophyte programmer has made two mistakes in the following code Correct them by changing no more than 13 characters void doubincrdoubleamp value double increment side effect increments value by increment value increment double val 15 fordouble i 01 i lt 05 i 01 increment val with successive doubles of i doubincrval ampi crossed out the amp cerr ltlt quotval quot ltlt val ltlt endl Q17 3 points What does the above code print out assuming you fixed it correctly a 75 b 75 c 33333333 d 15 e 25 IZI f 35 Q18 5 Points Part A Write two functions both called average that compute and return the average of an array One function acts on an array of doubles the second acts on an array of ints double averagedoub1e ar int arLen note assumes arLen gt0 double ave 0 forint i 0 i lt arLen i ave ari return ave double arLen cast isn t necessary just for your benefit double averageint ar int arLen note assumes arLen gt0 double ave 0 note the average is still a double forint i 0 i lt arLen i ave double ari again don t need the cast return ave double arLen again don t need the cast Part B What are the sequence and identity of the function arguments called It signature Part C What allows us to use the same two names in the same program function overloading Page 5 of 6 Points Lost this page Note I may substitute one question on scoping for one of the existing questions Note An extra Credit question is usually offered for folks who get bored during the test Page 6 0f 6 Points Lost this page CISC 1 8 1440 Review for Exam 1 Disclaimer while this list SHOULD cover everything itMAY not Don39t argue after the final ifthere happens to be something on the final that wasn39t mentioned in this list Topics 119125 21 221 3138310320 41464849 512 6264 Sort history of C where did it come from why it s different than C Compiling in C preprocessingcompilinglinking Preprocessor directives What is an algorithm Type Casting Promotion versus Truncation Preincrement vs Post Incremenet Looping WhileDo WhileFor Sentinal vs Counter Controller Know how to write loops Sequential Access Files using ifstreamofstream How to open and write to an ofstream how to open and read from an ifstream Random Numbers Pseudo random numbers how to seed Scaling numbers Signed vs Unsigned Numbers Storage Classes autostaticeXternregister Scope Rules Recursion Solve Base call call itself with simpler case why it s goodbad Inline Functions References Difference between Call by Value and Call by Reference Default Arguments Unary Scope Resolution Operator Function Overloading Arrays DeclaringInitializing Multi Dimension Arrays Passing Arrays to Functions Order NotationRunning times Functions Function De nitionPrototypes Bubble Sort Insertion Sort Linear Search Binary Search Structures CISC 1 8 1440 Review for Exam 2 Disclaimer while this list SHOULD cover everything itMAY not Don39t argue after the final ifthere happens to be something on the final that wasn39t mentioned in this list Topics 41 7 410 5158 512 76 171174 Linked List Tutorial on Web page Your notes you do have notes don39t you and my slides 811 What an array is how they work C Style Strings C Style Strings Differences between the two Know how to use copy and compare CStyle strings Pointers what are they creatingassigning Pointers the Null Pointer The address of amp operator The dereferencing operator Function passing using pointers Const Pointers 3 types Pointer Arithmetic Pointer Offset vs Pointer Subscript notation Static vs Dynamic Memory Allocation new and delete Allocating structs on the heap the gt operator Linked Lists How their de ned created Attaching nodes Searching Linked lists Losing NodesMemory Leaks Using an iteratordealing with empty lists
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'