1 CSC 101 Computer Science 1 – Exam 3 Fall 2021 Student Name: ________________________________________________ School ID: _____________________ Section Number: ______________ Sections: • H004 Test...

1 answer below »
no questions



1 CSC 101 Computer Science 1 – Exam 3 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. (3 pts each) ___________ 1. This is another name for the process of stepping through an array. A. Two Dimensional B. Elements C. Remove D. Out of Bounds E. Traversal F. Index G. Search H. Read I. Sub String J. Pass by Value K. Concatenation L. Erase M. String N. In Bounds O. Find P. Write Q. Pass by Reference R. One Dimensional S. Variable ___________ 2. This is the process of creating a combination of two or more strings into one new string. ___________ 3. 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. ___________ 4. This string function allows us to remove one or more characters at a certain position. ___________ 5. This type of argument passing results in the argument’s values being copied to the function’s parameters. ___________ 6. This is the numerical non-negative position of an element that is being accessed. ___________ 7. The process of outputting to a file is called this. ___________ 8. This is a cutout of a larger string, in a sense. ___________ 9. This are the individual components that make up an array. ___________ 10. This function allows a programmer to determine the index location of the first occurrence of a given character. Last Name:____________________ 3 ___________ 11. This is an issue when you try to access an element that does not exist in the array by using an invalid index. ___________ 12. The process of inputting from a file is called this. ___________ 13. This type of argument passing is when a variable argument is connected/attached to a function’s parameter. ___________ 14. This type of array organizes its elements in a table like fashion, and each element has two index numbers that represents its position in the array. ___________ 15. Arrays are automatically passed this way to a function. Last Name:____________________ 4 16. For the following array of size 5, indicate the index position each element in the array (5 pts). Element Value 56 89 43 30 21 Index 17. For the following, give the name of a C++ built in function that would allow us to do the following (5 pts). a. Determine if a character is a letter of the alphabet. b. Determine if a character is a punctuation mark. 18. 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 (5 pts). Last Name:____________________ 5 Analysis 19. Read the following code: const int SIZE = 11; int arr[SIZE] = { 49, 20, 19, 99, 92, 98, 74, 65, 84, 29, 97 }; int input; cout < "give="" me="" a="" number:="" ";="" cin="">> input; cout < "\n";="" for="" (int="" i="0;" i="">< size;="" i++)="" {="" if="" (arr[i]="">< input)="" cout="">< arr[i]="">< "\n";="" }="" a.="" if="" the="" user="" enters="" “42”="" as="" input="" into="" this="" program,="" indicate="" the="" output="" of="" the="" program.="" if="" there="" is="" no="" output,="" then="" specify="" “no="" output”.="" (2="" pts)="" b.="" if="" the="" user="" enters="" “12”="" as="" the="" input="" into="" this="" program,="" indicate="" the="" output="" of="" the="" program.="" if="" there="" is="" no="" output,="" then="" specify="" “no="" output”.="" (2="" pts)="" c.="" if="" the="" user="" enters="" “100”="" as="" the="" input="" into="" this="" program,="" indicate="" the="" output="" of="" the="" program.="" if="" there="" is="" no="" output,="" then="" specify="" “no="" output”.="" (2="" pts)="" d.="" describe="" the="" purpose="" of="" this="" program.="" (6="" pts)="" last="" name:____________________="" 6="" 20.="" read="" and="" analyze="" the="" following="" snippets="" of="" code:="" a.="" what="" is="" the="" output="" of="" code="" a?="" (3="" pts)="" b.="" what="" is="" the="" output="" of="" code="" b?="" (3="" pts)="" c.="" is="" there="" a="" difference?="" if="" so,="" explain="" why="" the="" difference="" occurred="" and="" what="" topic="" we="" learned="" about="" that="" explain="" the="" difference.="" (7="" pts)="" code="" a="" int="" function_a(int="" a,="" int="" b)="" {="" a="23;" b="32;" int="" c="a" +="" b;="" return="" c;="" }="" int="" main()="" {="" int="" x="9;" int="" y="5;" int="" z="function_a(x," y);="" cout="">< "x:="" "="">< x="">< "\n";="" cout="">< "y:="" "="">< y="">< "\n";="" cout="">< "z:="" "="">< z="">< "\n";="" }="" code="" b="" int="" function_a(int="" &a,="" int="" &b)="" {="" a="23;" b="32;" int="" c="a" +="" b;="" return="" c;="" }="" int="" main()="" {="" int="" x="9;" int="" y="5;" int="" z="function_a(x," y);="" cout="">< "x:="" "="">< x="">< "\n";="" cout="">< "y:="" "="">< y="">< "\n";="" cout="">< "z:="" "="">< z="">< "\n";="" }="" last="" name:____________________="" 7="" programming="" problem="" 21.="" the="" following="" program="" asks="" the="" user="" for="" their="" date="" of="" birth="" and="" favorite="" thing="" and="" generates="" a="" password="" for="" the="" user="" to="" use.="" the="" password="" is="" generated="" by="" adding="" their="" favorite="" thing="" at="" the="" beginning="" of="" the="" password,="" choosing="" a="" random="" symbol="" from="" a="" group="" of="" selected="" symbols,="" and="" then="" adding="" their="" date="" in="" reverse="" to="" the="" end="" of="" the="" password.="" complete="" the="" program="" by="" filling="" in="" the="" missing="" blanks="" below.="" (15="" pts)="" #include=""> #include #include using std::string; using std::cout; using std::cin; using std::getline; int rand_range(int start, int end); string reverse_str(string original); string generatePass(string dob, string favorite_thing); int main() { string name, dob, favorite_thing; string password; cout < "what="" is="" your="" dob,="" entered="" as="" mmddyyyy?="" ";="" getline(cin,="" dob);="" cout="">< "what="" is="" your="" favorite="" thing?="" ";="" getline(cin,="" favorite_thing);="" set="" the="" password="" to="" a="" generated="" password="" by="" calling="" the="" appropriate="" function,="" passing="" it="" the="" users="" date="" of="" birth="" and="" favorite="" thing.="" (3="" pts)="" ________________________________________________________________="" cout="">< "your="" new="" password="" is:="" ";="" cout="">< "\n"="">< password="">< "\n";="" }="" string="" generatepass(string="" dob,="" string="" favorite_thing)="" last="" name:____________________="" 8="" {="" string="" pass="" ;="" int="" random_index;="" symbols="" used="" in="" password.="" string="" symbols="!^&@.%" ;="" use="" concatenation="" to="" add="" the="" string="" in="" favorite_thing="" onto="" the="" back="" of="" pass.="" (3="" pts)="" __________________________________________________________________________="" use="" the="" rand_range="" function="" defined="" above="" to="" pick="" a="" random="" symbol="" in="" the="" symbols="" string="" and="" set="" it="" to="" random_index.="" hint:="" remember="" the="" rand_range="" function="" includes="" both="" the="" starting="" and="" ending="" number="" in="" the="" set="" of="" possible="" number.="" take="" this="" into="" consideration="" when="" determine="" start/end.="" (3="" pts)="" ____________________________________________________________________________="" concatenate="" the="" symbol="" onto="" pass.="" pass="" +="symbols[random_index];" reverse="" the="" date="" of="" birth="" and="" concatenate="" it="" onto="" pass.="" hint:="" a="" function="" has="" already="" been="" declared="" for="" reversing="" a="" string="" below.="" look="" at="" that="" function="" first.="" (3="" pts)="" ____________________________________________________________________________="" return="" pass;="" }="" uses="" system="" hardware="" devices="" to="" produce="" a="" random="" number="" between="" start="" and="" end.="" int="" rand_range(int="" start,="" int="" end)="" {="" std::random_device="" rd;="" obtain="" a="" random="" number="" from="" hardware="" std::mt19937="" gen(rd());="" seed="" the="" generator=""><> distr(start, end); // define the range return (int)distr(gen); // generate numbers } Last Name:____________________ 9 //This function reverses a string. string reverse_str(string original) { string rev; for (int i = 0; i < original.size(); i++) { //determine the index of the next character to append for the next character //from original. //hint: if "i" is 0, then rev_i should be size – 1. if "i" is 1, then rev_i should be size – 2. //(3 pts) _______________________________________________________________________ rev += original[rev_i]; } return rev; } sample output: original.size();="" i++)="" {="" determine="" the="" index="" of="" the="" next="" character="" to="" append="" for="" the="" next="" character="" from="" original.="" hint:="" if="" "i"="" is="" 0,="" then="" rev_i="" should="" be="" size="" –="" 1.="" if="" "i"="" is="" 1,="" then="" rev_i="" should="" be="" size="" –="" 2.="" (3="" pts)="" _______________________________________________________________________="" rev="" +="original[rev_i];" }="" return="" rev;="" }="" sample="">
Answered 1 days AfterNov 30, 2021

Answer To: 1 CSC 101 Computer Science 1 – Exam 3 Fall 2021 Student Name:...

Vaibhav answered on Dec 02 2021
121 Votes
1
CSC 101 Computer Science 1 – Exam 3
Fall 2021
Student Name: ________________________________________________
School ID: _____________________
Section Number: ______________
Sections:
• H004
Test Breakdown
Concept Knowledge 60 %
Program Analysis 25 %
Program Writing 15 %
Statem
ent 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. (3 pts each)
___________ 1.
This is another name for the process of
stepping through an array.
A. Two Dimensional
B. Elements
C. Remove
D. Out of Bounds
E. Traversal
F. Index
G. Search
H. Read
I. Sub String
J. Pass by Value
K. Concatenation
L. Erase
M. String
N. In Bounds
O. Find
P. Write
Q. Pass by Reference
R. One Dimensional
S. Variable
___________ 2.
This is the process of creating a combination
of two or more strings into one new string.
___________ 3.
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.
___________ 4.
This string function allows us to remove one
or more characters at a certain position.
___________ 5.
This type of argument passing results in the
argument’s values being copied to the
function’s parameters.
___________ 6.
This is the numerical non-negative position of
an element that is being accessed.
___________ 7. The process of outputting to a file is called this.
___________ 8. This is a cutout of a larger string, in a sense.
___________ 9. This are the individual components that make up an array.
___________ 10.
This function allows a programmer to determine the index location of the
first occurrence of a given character.
Traversal
Concatenation
One Dimensional
Pass by Value
Remove
Index
Write
Substring
Elements
Find
Last Name:____________________
3

___________ 11.
This is an issue when you try to access an element that does not exist in the
array by using an invalid index.
___________ 12. The process of inputting from a file is called this.
___________ 13.
This type of argument passing is when a variable argument is
connected/attached to a function’s parameter.
___________ 14.
This type of array organizes its elements in a table like fashion, and each
element has two index numbers that represents its position in the array.
___________ 15. Arrays are automatically passed this way to a function.
Out of bounds
Read
Pass by Reference
Two Dimensional
Pass by Reference
Last Name:____________________
4
16. For the following array...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here