Random Numbers With Rnd

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Jhangen
J
Jhangen
Community Contributor
Quizzes Created: 3 | Total Attempts: 4,292
| Attempts: 158 | Questions: 16
Please wait...
Question 1 / 16
0 %
0/100
Score 0/100
1. What line in the code makes cmdFive produce an integer?

Explanation

Integer is the data type for integer numbers and the variable UpTo5 is declared as a Integer in this declaration statement.

Submit
Please wait...
About This Quiz
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... see morethe 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. see less

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

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.

Submit
3. Why or why not?

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.

Submit
4. What line in the code makes cmdLessOne produce a decimal?

Explanation

Single is the data type for decimal numbers and the variable LessOne is declared as a Single in this declaration statement.

Submit
5. What line in the code makes cmdTen produce a decimal?

Explanation

Single is the data type for decimal numbers and the variable LessTen is declared as a Single in this declaration statement.

Submit
6. What line in the code makes cmd100 produce an integer?

Explanation

Integer is the data type for integer numbers and the variable UpTo100 is declared as a Integer in this declaration statement.

Submit
7. What type of numbers exist between 0 and 1?

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.

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

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.

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

Explanation

To get a random number between 0 and any number x, multiply Rnd by that number x.

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

Explanation

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

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

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.

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

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

Submit
13. 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.

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.

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

Explanation

Example: 33 * .1 results in 3.3
Example: 33 * .5 results in 16.5
Example: 33 * .9999 results in 32.9967

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

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

Submit
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 Integer
Dim UpToTop As Integer

Explanation

To get a random number between 0 and a number in the variable Top, multiply Rnd by the variable Top.

Submit
View My Results

Quiz Review Timeline (Updated): May 6, 2024 +

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
Cancel
  • All
    All (16)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What line in the code makes cmdFive produce an integer?
When you run your RandomNumber.frm program, do you get the same exact...
Why or why not?
What line in the code makes cmdLessOne produce a decimal?
What line in the code makes cmdTen produce a decimal?
What line in the code makes cmd100 produce an integer?
What type of numbers exist between 0 and 1?
What line of code guarantees that the results will be truly random?
Write the line of code that will put a random number between 0...
When you multiply a number between 0 and 1 by 10, how many digits are...
What is the keyword in Visual Basic that produces a random number...
Describe the number that will be stored in memory because of this line...
To have a program user pick the highest number, use a textbox to get...
What must Rnd be multiplied by to produce a number between 0 and...
Describe the number that will be stored in the variable, UpTo5,...
Which of these could be the assignment statement for putting the...
Alert!

Advertisement