Random Numbers With Rnd

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Jhangen
J
Jhangen
Community Contributor
Quizzes Created: 3 | Total Attempts: 3,927
Questions: 16 | Attempts: 142

SettingsSettingsSettings
Random Numbers With Rnd - Quiz


Study the RandomNumber. Frm code and its output first. Use your answers that you put on paper from the assignment. After you are finished, read the corrections and the explanations that go with them. Even if you got all the answers correct, please read the explanations that are provided below the problem. If you did not get 100%, click on Try Again at the bottom. Correct your paper answers as well.


Questions and Answers
  • 1. 

    When you run your RandomNumber.frm program, do you get the same exact results as the example shown on the direction sheet?

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    Explanation
    The answer is "No" because when running the RandomNumber.frm program, the results may vary due to the nature of random numbers. Random numbers are generated based on certain algorithms and seed values, so each time the program is run, it may produce different results. Therefore, it is unlikely that the exact same results as the example shown on the direction sheet will be obtained.

    Rate this question:

  • 2. 

    Why or why not?

    • A.

      The output is the same because I did it correctly.

    • B.

      The output is different because the numbers are random.

    Correct Answer
    B. The output is different because the numbers are random.
    Explanation
    The given correct answer states that the output is different because the numbers are random. This implies that the outcome of the task or calculation is influenced by the random nature of the numbers involved. As a result, even if the person claims to have completed the task correctly, the randomness of the numbers used would still lead to a different output. Therefore, the correct answer suggests that the randomness of the numbers is the reason for the difference in output.

    Rate this question:

  • 3. 

    What line in the code makes cmdLessOne produce a decimal?

    • A.

      Dim LessOne As Single

    • B.

      Randomize

    • C.

      LessOne = Rnd

    • D.

      LblLessOne = LessOne

    Correct Answer
    A. Dim LessOne As Single
    Explanation
    Single is the data type for decimal numbers and the variable LessOne is declared as a Single in this declaration statement.

    Rate this question:

  • 4. 

    What line in the code makes cmdTen produce a decimal?

    • A.

      Dim LessTen As Single

    • B.

      Randomize

    • C.

      LessTen = 10 * Rnd

    • D.

      LblLessTen = LessTen

    Correct Answer
    A. Dim LessTen As Single
    Explanation
    Single is the data type for decimal numbers and the variable LessTen is declared as a Single in this declaration statement.

    Rate this question:

  • 5. 

    What line in the code makes cmdFive produce an integer?

    • A.

      Dim UpTo5 As Integer

    • B.

      Randomize

    • C.

      UpTo5 = 5 * Rnd

    • D.

      LblUpTo5 = UpTo5

    Correct Answer
    A. Dim UpTo5 As Integer
    Explanation
    Integer is the data type for integer numbers and the variable UpTo5 is declared as a Integer in this declaration statement.

    Rate this question:

  • 6. 

    What line in the code makes cmd100 produce an integer?

    • A.

      Dim UpTo100 As Integer

    • B.

      Randomize

    • C.

      UpTo100 = 100 * Rnd

    • D.

      LblUpTo100 = UpTo100

    Correct Answer
    A. Dim UpTo100 As Integer
    Explanation
    Integer is the data type for integer numbers and the variable UpTo100 is declared as a Integer in this declaration statement.

    Rate this question:

  • 7. 

    What line of code guarantees that the results will be truly random?

    • A.

      Dim UpTo100 As Integer

    • B.

      Randomize

    • C.

      UpTo100 = 100 * Rnd

    • D.

      LblUpTo100 = UpTo100

    Correct Answer
    B. Randomize
    Explanation
    The line of code "Randomize" guarantees that the results will be truly random. This function initializes the random number generator with a seed value based on the system timer. By calling this function before generating random numbers, it ensures that each time the program runs, a different seed value is used, resulting in a different sequence of random numbers.

    Rate this question:

  • 8. 

    What is the keyword in Visual Basic that produces a random number between 0 and 1?

    • A.

      Randomize

    • B.

      Rnd

    • C.

      LessOne

    • D.

      Random

    Correct Answer
    B. Rnd
    Explanation
    The keyword in Visual Basic that produces a random number between 0 and 1 is "Rnd". This keyword is used in conjunction with the "Randomize" keyword to initialize the random number generator. By calling "Rnd", a random number between 0 and 1 is generated.

    Rate this question:

  • 9. 

    What type of numbers exist between 0 and 1?

    • A.

      Integers

    • B.

      Decimals (Single)

    Correct Answer
    B. Decimals (Single)
    Explanation
    The correct answer is "Decimals (Single)" because between 0 and 1, there are a range of numbers that are not whole numbers or integers. These numbers are called decimals, and in this case, specifically "single" decimals, which means they have only one digit after the decimal point. Decimals represent fractions or parts of a whole number, allowing for more precise representation of values between whole numbers.

    Rate this question:

  • 10. 

    When you multiply a number between 0 and 1 by 10, how many digits are to the left of the decimal point?

    • A.

      0

    • B.

      1

    • C.

      2

    • D.

      10

    Correct Answer
    B. 1
    Explanation
    Example: .34201 * 10 results in 3.4201 The 3 is the only digit to the left of the decimal point.

    Rate this question:

  • 11. 

    Describe the number that will be stored in memory because of this line of code in cmdTen. LessTen = 10 * Rnd

    • A.

      A random decimal number less than 10 such as 2.3482 or 9.3627

    • B.

      A random integer less than 10 such as 2 or 9

    • C.

      A random decimal number between 0 and 1 such as .23 or .93

    • D.

      A random integer as small or big as the computer will allow

    Correct Answer
    A. A random decimal number less than 10 such as 2.3482 or 9.3627
    Explanation
    Example: 10 * .34201 results in 3.4201
    Example: 10 * .9999 results in 9.999
    Example: 10 * .1047 results in 1.047
    Example: 10 * .00005 results in 0.0005

    Rate this question:

  • 12. 

    Describe the number that will be stored in the variable, UpTo5, because of this line of code in cmdFive. UpTo5 = 5 * Rnd

    • A.

      A random decimal less than 5

    • B.

      A random decimal from 0 to 5

    • C.

      A random integer from 0 to 5

    • D.

      A random integer from 0 to 5000

    Correct Answer
    C. A random integer from 0 to 5
    Explanation
    Since UpTo5 is declared as an integer whatever number is stored in it must be an integer. When an attempt to store a decimal occurs, the digits after the decimal point will be chopped off. Depending on the programming language the number might be rounded to the nearest integer.
    Example: 5 * .00005 results in .00025 which rounds to 0 Example: 5 * .1047 results in .5235 which rounds to 1
    Example: 5 * .34201 results in 1.71005 which rounds to 2
    Example: 5 * .541 results in 2.705 which rounds to 3
    Example: 5 * .6 results in 3
    Example: 5 * .8 results in 4
    Example: 5 * .987 results in 4.935 which rounds to 5

    Rate this question:

  • 13. 

    What must Rnd be multiplied by to produce a number between 0 and 33?

    • A.

      300

    • B.

      .3

    • C.

      3.3

    • D.

      33

    • E.

      13

    Correct Answer
    D. 33
    Explanation
    Example: 33 * .1 results in 3.3
    Example: 33 * .5 results in 16.5
    Example: 33 * .9999 results in 32.9967

    Rate this question:

  • 14. 

    Write the line of code that will put a random number between 0 and 33 in the variable, UpTo33.

    • A.

      UpTo33 = Rnd

    • B.

      UpTo33 = 33 * Rnd

    • C.

      UpTo33 = 10 * Rnd

    • D.

      UpTo33 = Rnd + 13

    Correct Answer
    B. UpTo33 = 33 * Rnd
    Explanation
    To get a random number between 0 and any number x, multiply Rnd by that number x.

    Rate this question:

  • 15. 

    To have a program user pick the highest number, use a textbox to get the number and multiply Rnd by the numerical variable where that number is stored.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    This statement is true because to have a program user pick the highest number, we can use a textbox to get the number input from the user. Then, we can generate a random number using the Rnd function and multiply it by the numerical variable where the highest number is stored. This way, we can ensure that the user picks the highest number based on the random value generated.

    Rate this question:

  • 16. 

    Which of these could be the assignment statement for putting the random integer from 0 to the top number the user provided, into a variable in memory, if these declarations are given?Dim Top As IntegerDim UpToTop As Integer

    • A.

      UpToTop = 10 * Rnd

    • B.

      UpToTop = Top * Rnd

    • C.

      UpToX = Top * Rnd

    • D.

      UpToHigh = Top * Rnd

    • E.

      UpToX = X * Rnd

    Correct Answer
    B. UpToTop = Top * Rnd
    Explanation
    To get a random number between 0 and a number in the variable Top, multiply Rnd by the variable Top.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • May 06, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 27, 2009
    Quiz Created by
    Jhangen
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.