
Procedures

Quiz
•
Computers
•
12th Grade
•
Hard
Ms Seccafico
Used 99+ times
FREE Resource
6 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
In the following procedure, the parameter str is a string and the parameter num is a number.
PROCEDURE printArgs(str, num)
{
DISPLAY(num)
DISPLAY(str)
DISPLAY(num)
}
Consider the following code segment.
printArgs("**", 1)
printArgs("*", 2)
What is displayed as a result of executing the code segment?
1 * 1 2 ** 2
1 ** 1 2 * 2
* 1 * ** 2 **
** 1 ** * 2 *
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following procedures.
PROCEDURE proc1(str)
{
DISPLAY(str)
DISPLAY("happy")
}
PROCEDURE proc2(str1, str2)
{
proc1(str2)
DISPLAY(str1)
}
What is displayed as a result of the procedure call proc2("birthday", "to you") ?
birthday happy to you
birthday happy birthday
to you birthday happy
to you happy birthday
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following procedure.
PROCEDURE doSomething(num1, num2)
{
DISPLAY(num1)
RETURN(num1)
DISPLAY(num2)
}
Consider the following statement.
DISPLAY(doSomething(10, 20))
What is displayed as a result of executing the statement above?
10 10
10 20
10 10 20
10 20 10
4.
MULTIPLE SELECT QUESTION
1 min • 1 pt
Which of the following are benefits of procedural abstraction?
Select two answers.
Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers.
Procedural abstraction eliminates the need for programmers to document their code.
Procedural abstraction makes it easier for people to read computer programs.
Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
A student is developing a program that allows users to look up the definitions of words that appear in a book.
The student plans to perform a large number of searches through a dictionary containing words and their definitions. The student will use a procedure written by a computer scientist to quickly search the dictionary (and knows that the procedure will return a definition if one is available). The student cannot modify the search procedure written by the computer scientist but can call the procedure by supplying a word.
Which of the following is a true statement about the student’s use of the computer scientist’s search procedure?
The student is changing the search procedure’s internal abstractions.
The student is modifying the search procedure to take a definition as an argument and return the corresponding word.
The student is reusing the computer scientist’s procedural abstraction by knowing what the procedure does without knowing how it does it.
The student is reusing the computer scientist’s procedural abstraction by using duplicate code each time a search needs to occur.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
A student wrote the following procedure to calculate the sum of the integers from 1 to 5.
The student later decides to modify the procedure to calculate the sum of the integers from 1 to max, which represents any positive integer greater than 1.
Which of the following changes should be made to the procedure to meet the student’s goal?
I. The procedure should take max as an input parameter. II. The condition in the REPEAT UNTIL block should be changed to count > max.
III. The condition in the REPEAT UNTIL block should be changed to max < 5.
I only
II only
I and II
I and III
Similar Resources on Wayground
8 questions
Question Type: Pseudocode

Quiz
•
10th - 12th Grade
10 questions
AP Computer Science Principles - Unit 7: Parameters, Returns

Quiz
•
9th - 12th Grade
10 questions
2.1.1. Thinking Abstractly

Quiz
•
12th Grade
10 questions
OOP

Quiz
•
9th - 12th Grade
10 questions
CSP Unit 3 Data Representation

Quiz
•
9th - 12th Grade
10 questions
Computational Thinking

Quiz
•
9th - 12th Grade
7 questions
CSP Big Ideas

Quiz
•
9th - 12th Grade
10 questions
AP CSP Boolean Logic 4

Quiz
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade