Random Numbers + Review

Random Numbers + Review

12th Grade

8 Qs

quiz-placeholder

Similar activities

Hệ Điều Hành Của Máy Tính

Hệ Điều Hành Của Máy Tính

10th Grade - University

10 Qs

tin 10 l11

tin 10 l11

12th Grade

10 Qs

Computer Basics 2 - CESA

Computer Basics 2 - CESA

7th Grade - University

10 Qs

WAN Sesi 1

WAN Sesi 1

1st Grade - University

10 Qs

HARD DISK DRIVE

HARD DISK DRIVE

11th - 12th Grade

10 Qs

ukuran data

ukuran data

1st - 12th Grade

10 Qs

Chapter 2: Input Device

Chapter 2: Input Device

12th Grade - University

12 Qs

TRẮC NGHIỆM TIN 12 KỲ II

TRẮC NGHIỆM TIN 12 KỲ II

10th - 12th Grade

10 Qs

Random Numbers + Review

Random Numbers + Review

Assessment

Quiz

Computers

12th Grade

Practice Problem

Medium

Created by

James Luong

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Media Image

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

Media Image

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.

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?