another test
1 CSC 101 Computer Science 1 – Final Exam Fall 2021 Student Name: ________________________________________________ School ID: _____________________ Section Number: ______________ Sections: • H004 Test Breakdown Concept Knowledge 60 % Program Analysis 25 % Program Writing 15 % Statement on Integrity This test is closed note, closed book, closed electronic device, and closed partner. You are permitted a calculator and a writing utensil. Any violation of these policies will result in an automatic zero and an immediate referral to the Honor Code office. Last Name:____________________ 2 Grade: ________________________________ Concept Knowledge Match the following definitions and statements to the terms listed on the right. Note that some terms may be used more than once while others may not be used at all. (1.5 pts each) Part 1 ___________ 1. This is the smallest unit of a computer program. Part 1 Terms A. Else If Statement B. Bit C. Output D. Hardware E. Programming Statement F. Process G. Relational H. If Statement I. Software J. Else Statement K. Input L. Comment M. Token N. Logical O. Byte ___________ 2. This allows us to incorporate a one-way selection in our program, where a set of statements get executed when an expression evaluates to true. ___________ 3. This is a single line of code in a computer program. ___________ 4. This is a type of operator that allows us to “chain” together other expressions to form complex logical/relational expressions. ___________ 5. This allows us to incorporate a two-way selection in our program, where one set of statements execute when an expression evaluates to true while the other set execute when the expression evaluates to false. ___________ 6. In this phase of a program’s computation, data is collected/gathered/generated from an outside source. ___________ 7. This is the basic unit of measurement of computer data. ___________ 8. This allows us to incorporate a multi way selector in our program. ___________ 9. This is used to annotate and describe computer code and is ignored when the program is executed. ___________ 10. This is the physical/tangible components of a computer. Last Name:____________________ 3 Part 2 ___________ 11. This is the phase of a for loop where the counting variable in initialized/created. Part 2 Terms A. Syntax B. Design C. Pre-Test D. Initialization E. Runtime F. Post Test G. Step H. Develop I. Argument J. Flowcharts K. Prototype L. Logical M. Condition N. Sentinel O. Pseudocode P. Parameter Q. Test R. Body ___________ 12. This type of error occurs when the operating system/computer cannot execute a line of code in a program while the program is executing. ___________ 13. In this stage of the Waterfall Model, the app is checked and executed to ensure there are no errors in the program. ___________ 14. This will make a function one that returns nothing back to where it’s called. ___________ 15. This type of variable is one that can be used throughout the entire program. ___________ 16. This type of design approach involves creating a high level/informal description of a program that does not adhere to any programming language’s rules. ___________ 17. A do while loop is called this since the body executes first rather than the expression. ___________ 18. This is a type of variable that a function uses to store its input. ___________ 19. This allows us to redefine the scope of a function so that we may define it below main. ___________ 20. This type of loop repeats as long as the user needs to enter input. Last Name:____________________ 4 Part 3 ___________ 21. The process of inputting from a file is called this. Part 3 Terms A. Reading B. Element C. In Bounds D. Out of Bounds E. Looping F. Substring G. Erase H. Pass by Reference I. Traversing J. Index K. Find L. Pass by Value M. Writing ___________ 22. The process of outputting to a file is called this. ___________ 23. This is another name for the process of stepping through an array. ___________ 24. This is the numerical non-negative position of an element that is being accessed. ___________ 25. This type of argument passing results in the argument’s values being copied to the function’s parameters. ___________ 26. This is a cutout of a larger string, in a sense. ___________ 27. This is an issue when you try to access an element that does not exist in the array by using an invalid index. ___________ 28. This type of array organizes its elements in a linear fashion, and each element has one index number that represents its position in the array. ___________ 29. This function allows a programmer to determine the index location of the first occurrence of a given character. ___________ 30. These are the individual components that make up an array. Last Name:____________________ 5 31. Briefly describe 2 reasons why need functions. (7 pts) 32. Briefly explain why it is unfeasible to only use variables in a program to store large amounts of data, and why arrays make data organization easier (8 pts). Last Name:____________________ 6 Analysis 33. Read the following code: const int SIZE = 9; int arr[SIZE] = { 90, 23, 86, 78, 45, 102, 91, 594, 33 }; int input; cout < "give="" me="" a="" number:="" ";="" cin="">> input; cout < "\n";="" for="" (int="" i="0;" i="">< size;="" i++)="" {="" if="" (arr[i]=""> input && arr[i] % 2 == 0) cout < arr[i]="">< "\n";="" }="" a.="" if="" the="" user="" enters="" “23”="" as="" input="" into="" this="" program,="" indicate="" the="" output="" of="" the="" program.="" if="" there="" is="" no="" output,="" then="" specify="" “no="" output”.="" (1="" pts)="" b.="" if="" the="" user="" enters="" “800”="" as="" the="" input="" into="" this="" program,="" indicate="" the="" output="" of="" the="" program.="" if="" there="" is="" no="" output,="" then="" specify="" “no="" output”.="" (1="" pts)="" c.="" if="" the="" user="" enters="" “78”="" as="" the="" input="" into="" this="" program,="" indicate="" the="" output="" of="" the="" program.="" if="" there="" is="" no="" output,="" then="" specify="" “no="" output”.="" (1="" pts)="" d.="" describe="" the="" purpose="" of="" this="" program.="" (2="" pts)="" last="" name:____________________="" 7="" 34.="" take="" the="" following="" examples="" and="" match="" each="" to="" its="" token="" type="" (5="" pts):="" float="" ________________________="" function_b="" ________________________="" 892.31="" ________________________="" &&="" ________________________="" else="" ________________________="" 35.="" read="" the="" following="" code="" (5="" pts):="" a.="" what="" is="" the="" return="" type="" of="" this="" function(1="" pt)="" b.="" what="" are="" the="" parameters="" of="" this="" function?="" what="" are="" their="" data="" types?="" (1="" pt)="" c.="" what="" type="" of="" argument="" passing="" does="" this="" function="" implement?="" (1="" pt)="" d.="" briefly="" describe="" how="" this="" function="" works.="" (2="" pts)="" void="" swap(int="" &a,="" int="" &b)="" {="" int="" temp="a;" a="b;" b="temp;" }="" last="" name:____________________="" 8="" 36.="" take="" the="" following="" code:="" code="" a="" code="" b="" int="" x;="" cout="">< "enter="" your="" grade:="" ";="" cin="">> x; cout < "you="" received="" a="" grade="" of="" ";="" if="" (x="">< 60)="" cout="">< "f";="" else="" if="" (x="">< 70)="" cout="">< "d";="" else="" if="" (x="">< 80)="" cout="">< "c";="" else="" if="" (x="">< 90)="" cout="">< "b";="" else="" cout="">< "a";="" cout="">< "\n";="" int="" x;="" cout="">< "enter="" your="" grade:="" ";="" cin="">> x; cout < "you="" received="" a="" grade="" of="" ";="" if="" (x="">< 60)="" cout="">< "f";="" if="" (x="">< 70)="" cout="">< "d";="" if="" (x="">< 80)="" cout="">< "c";="" if="" (x="">< 90)="" cout="">< "b";="" else="" cout="">< "a";="" cout="">< "\n";="" a.="" specify="" the="" final="" output="" of="" code="" a="" if="" x="" were="" the="" following="" values:="" [45,="" 90,="" 78,="" 64]="" (1="" pt)="" b.="" specify="" the="" final="" output="" of="" code="" b="" if="" x="" were="" the="" following="" values:="" [45,="" 90,="" 78,="" 64]="" (1="" pt)="" c.="" when="" you="" compare="" the="" output="" of="" code="" a="" to="" code="" b,="" do="" you="" notice="" a="" difference?="" if="" so,="" describe="" the="" difference="" and="" why="" the="" difference="" occurred.="" (3="" pts)="" last="" name:____________________="" 9="" 37.="" the="" following="" program="" has="" a="" total="" of="" 5="" errors="" in="" it.="" list="" the="" line="" number="" of="" each="" error="" and="" determine="" whether="" the="" error="" is="" a="" syntax="" or="" logical="" error.="" (5="" pts)="" line="" 01:="" const="" int="" size="5;" line="" 02:="" int="" arr[size]="{89," 104,="" 90,="" 83,="" 200};="" line="" 03:="" line="" 04:="" int="" sum_evens="0;" line="" 05:="" sum_odds="0;" line="" 06:="" line="" 07:="" cout="">> "Enter the numbers for your list: "; Line 08: Line 09: for (int i = 0; i > SIZE; i++) Line 10: { Line 11: cin >> arr[k]; Line 12: } Line 13: Line 14: for (int i = 0; i < size; i++) line 15: { size;="" i++)="" line="" 15:=""> size; i++) line 15: {>