
Random Numbers + Review
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Medium
James Luong
Used 2+ times
FREE Resource
Enhance your content in a minute
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What numbers can generate?
rand()%5 + 1
1,2,3,4,5
0,1,2,3,4,5
1,2,3,4,5,6
0,1,2,3,4,5,6
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
To create a random number between 10 and 15 use...
rand()%6+10
rand()%10+5
rand()%15
rand()%15+10
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
For a 6 sided die (rolls 1,2,3,4,5,6) you should use...
rand()%6
rand()%5 + 1
rand()%6 + 1
rand()%7 + 6
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does = mean ?
It is the assignment operator.
It sets the variable on the left side equal to what is on the right side.
It is the equality operator. It is used to check if both sides are equal
Answer explanation
An easy way to remember is that 1 equal sign is 1-way. It sets the left side equal to the right side. 2 equal signs are 2-way, the check if BOTH are the same.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does == mean ?
It is the assignment operator.
It sets the variable on the left side equal to what is on the right side.
It is the equality operator. It is used to check if both sides are equal
Answer explanation
An easy way to remember is that 1 equal sign is 1-way. It sets the left side equal to the right side. 2 equal signs are 2-way, the check if BOTH are the same.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why does this code always print "Oh no, your number was 1"
The assignment operator was used instead of the equality operator
The conditions for the if, else if, and else statements are incorrect
The random number was generated incorrectly
An uninitialized variable is used
Answer explanation
random = 1 in the condition resets the variable random to 1 regardless of whatever random number was generated
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
This code should should run until a 1 is rolled but 2 of these errors block it from compiling
'else' without a previous 'if'
What is the issue?
There should be NO SEMICOLONS after a while loop or if statement
true should be capitalized in an infinite loop
The conditions are written incorrectly
The random numbers are generated incorrectly
Answer explanation
While most lines end in a semicolon, loops and conditions DO NOT end in a semicolon.
8.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What values should be used for y & n in this code?
(The random numbers generated should cover ONLY the options in the if statements)
y = 3, n = 0
y = 2, n = 1
y = 3, n = 1
y = 2, n = 2
Answer explanation
There are 3 options so we should use %3.
The options start at 1 so we should use +1.
Similar Resources on Wayground
10 questions
Intro to Windows Server 2012
Quiz
•
12th Grade
10 questions
Tree and Planar Graph
Quiz
•
University
10 questions
CodeMonkey for B.Ed IT
Quiz
•
University
10 questions
STM10163_T1:INTRODUCTION TO DATABASE CONCEPT
Quiz
•
University
10 questions
TOOLS FOR AD & TECHNOLOGY DEVELOPMENT (W4-W6)
Quiz
•
University
10 questions
Bài 25 tin 10
Quiz
•
9th Grade - University
10 questions
Understanding Email, Contacts and Calendaring
Quiz
•
University
10 questions
Logika Fuzzy
Quiz
•
University
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
Discover more resources for Computers
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
15 questions
Christmas Song Emoji Pictionary
Quiz
•
7th - 12th Grade
20 questions
Christmas Movies
Quiz
•
1st - 12th Grade
55 questions
CHS Holiday Trivia
Quiz
•
12th Grade
20 questions
Christmas Movie Trivia
Quiz
•
9th - 12th Grade
29 questions
christmas facts
Lesson
•
5th - 12th Grade
20 questions
Christmas Trivia
Quiz
•
5th - 12th Grade
20 questions
Stages of Meiosis
Quiz
•
9th - 12th Grade
