Which of the following algorithms displays the correct distance for all possible values of num1 and num2 ?
Mathematical Expressions Quiz (MCQs)

Quiz
•
Computers
•
10th Grade
•
Easy
stay ss
Used 14+ times
FREE Resource
6 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Step 1:
Add num1 and num2 and store the result in the variable sum.
Step 2: Take the absolute value of sum and display the result.
Step 1:
Subtract num1 from num2 and store the result in the variable diff.
Step 2:
Take the absolute value of diff and display the result.
Step 1:
Take the absolute value of num1 and store it in the variable absNum1.
Step 2:
Take the absolute value of num2 and store it in the variable absNum2.
Step 3:
Add absNum1 and absNum2 and display the result.
Step 1:
Take the absolute value of num1 and store it in the variable absNum1.
Step 2:
Take the absolute value of num2 and store it in the variable absNum2.
Step 3:
Subtract absNum1 from absNum2 and display the result.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A teacher has a goal of displaying the names of 2 students selected at random from a group of 30 students in a classroom. Any possible pair of students should be equally likely to be selected. Which of the following algorithms can be used to accomplish the teacher’s goal?
A
Step 1:
Assign each student a unique integer from 1 to 30.
Step 2:
Generate a random integer n from 1 to 15.
Step 3:
Select the student who is currently assigned integer n and display the student’s name.
Step 4:
Generate a new random integer n from 16 to 30.
Step 5:
Select the student who is currently assigned integer n and display the student’s name.
Step 1:
Assign each student a unique integer from 1 to 30.
Step 2:
Generate a random integer n from 1 to 30.
Step 3:
Select the student who is currently assigned integer n and display the student’s name.
Step 4:
Generate a new random integer n from 1 to 30.
Step 5:
Select the student who is currently assigned integer n and display the student’s name.
Step 1:
Assign each student a unique integer from 1 to 30.
Step 2:
Generate a random odd integer n from 1 to 29.
Step 3:
Select the student who is currently assigned integer n and display the student’s name.
Step 4:
Generate a new random even integer n from 2 to 30.
Step 5:
Select the student who is currently assigned integer n and display the student’s name.
Step 1:
Assign each student a unique integer from 1 to 30.
Step 2:
Generate a random integer n from 1 to 30.
Step 3:
Select the student who is currently assigned integer n and display the student’s name.
Step 4:
The student who was selected in the previous step is assigned 0. All other students are reassigned a unique integer from 1 to 29.
Step 5:
Generate a new random integer n from 1 to 29.
Step 6:
Select the student who is currently assigned integer n and display the student’s name.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following code segments can be used to interchange the values of the variables num1 and num2 ?
num 1 - num 2
num 2 - num 1
temp - num 1
num 1 - temp
num2- num 1
temp - num 1
num 2 - num 1
num 1 - temp
temp - num 1
num 1- num 2
num 2 - temp
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following code segments can be used to update the values of the variables as shown in the table?
temp ← word1
word3 ← word1
word1 ← temp
temp ← word1
word1 ← word3
word3 ← temp
temp ← word1
word1 ← word2
word2 ← word3
word3 ← temp
temp ← word3
word3 ← word2
word2 ← word1
word1 ← temp
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following initial values of the variable y would result in the variable z being set to 2 after the code segment is executed?
1
2
3
4
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is displayed as a result of executing the code segment?
a - 10
b - 20
c - 30
d - 40
x - 20
b- x+b
a- x+1
d- c + d/2
dispaly a,b,c,d
10 20 30 40
21 30 40 50
21 40 30 40
21 40 30 50
Similar Resources on Quizizz
11 questions
AP CSP MCQ Review Session 3 Quiz

Quiz
•
10th Grade
10 questions
Programação em C

Quiz
•
10th - 12th Grade
9 questions
OCR GCSE CS - 2.1 ERL sorts and searches

Quiz
•
10th - 11th Grade
10 questions
Uji Kemampuan Algoritma dan Pemrograman

Quiz
•
10th Grade
7 questions
026. A - G Extra Help

Quiz
•
9th - 12th Grade
11 questions
Control Structures - Selection in Python

Quiz
•
8th Grade - University
9 questions
Computer Science Foundations - Module 4 Review

Quiz
•
9th - 11th Grade
10 questions
DFD- DIAGRAMAS DE FLUJO

Quiz
•
10th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Computers
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade
10 questions
Identifying equations

Quiz
•
KG - University