Search Header Logo

Pseudocode Quiz

Authored by John Streety

Computers

10th Grade

Used 2+ times

Pseudocode Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the pseudocode procedure findMaxDigit, which is intended to return the maximum digit in the integer num. For example, if num is 294, findMaxDigit returns 9 because 9 is the maximum digit in 294. // precondition: num is a positive integer greater than 0 int findMaxDigit (int num) int maxDigit ← /* missing code segment */ while (num > 0) int digit ← num % 10 if ( digit > maxDigit ) maxDigit ← digit end if num ← num / 10 //Division symbol uses integer division end while return maxDigit end findMaxDigit Which of the following could replace /* missing code segment */ so that findMaxDigit works as intended?

num / 10 + 10

num % 10

num * 10

num + 10

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following function: void drawTriangle () // print a line break after each print statement print "*" print "**" print "***" print "****" end drawTriangle What would happen as a result of calling drawTriangle()?

**********

* ** *** ****

*

****

**

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following pseudocode procedure. // precondition: k is a positive integer greater than 1 void mystery(int k) for (int c = 1; c < k; c = c + 1) print c + " " end for end mystery Which of the following best describes procedure mystery?

It returns all the values from 1 to k.

It returns all the values from 1 to k-1.

It prints all the values from 1 to k.

It prints all the values from 1 to k - 1.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following procedure and procedure call: void practice( int Y) int X ← 10 Y ← Y + 5 if ( X > Y) print “Hello” else print “world” end if end practice practice(5) What would print as a result of executing the code?

Nothing because the function is defined as VOID

Hello

Hello world

world

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following procedure header: int getSum(int num1, int num2, int num3) Which procedure call is valid?

getSum("A", 96, 95)

getSum(94.5, 96, 95)

getSum(96, 95)

getSum(getSum(92, 93, 95), 96, 95)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the pseudocode procedure swapValues that is intended to swap the values of the two integer variables m and n. void swapValues( int m, int n) /* missing code segment */ end swapValues Which of the following could replace /* missing code segment */ so that swapValues works as intended?

int temp ← m n ← m m ← n

int temp ← m m ← n n ← temp

int temp ← n m ← n n ← temp

int temp ← n n ← m m ← n

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following pseudocode procedure and procedure call: void practicePassing( pass-by-reference int X, pass-by-value int Y) Y = X / 2 // Division symbol uses integer division X = Y + 3 print X, Y end practicePassing Int i = 2 Int j = 3 practicePassing( i, j) print i, j What would print as a result of executing the code?

4 1 4 3

4 1 2 3

6 1 6 3

4 1 2 1

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?