Robot C - Variables

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 Zmolls
Z
Zmolls
Community Contributor
Quizzes Created: 7 | Total Attempts: 15,007
Questions: 11 | Attempts: 226

SettingsSettingsSettings
Robot Quizzes & Trivia

To start the quiz, enter your LAST NAME FIRST and press start.


Questions and Answers
  • 1. 

    The output of a sensor is always in the form of a…

    • A.

      Value.

    • B.

      Decimal.

    • C.

      Threshold.

    • D.

      Frequency.

    Correct Answer
    A. Value.
    Explanation
    The output of a sensor is always in the form of a value. Sensors are designed to measure various physical quantities such as temperature, pressure, light intensity, etc. and provide a numerical value as the output. This value represents the measurement or reading obtained by the sensor and can be used for further analysis or control purposes. The other options, such as decimal, threshold, and frequency, do not accurately describe the general output of a sensor.

    Rate this question:

  • 2. 

    When a programmer “declares” a variable, they…

    • A.

      Shout out the value so the entire world can hear it.

    • B.

      Specify the type of value and give it a name.

    • C.

      Specify the aspect of the variable.

    • D.

      Create a line of code that will display a value.

    Correct Answer
    B. Specify the type of value and give it a name.
    Explanation
    When a programmer "declares" a variable, they specify the type of value and give it a name. This means that they define the data type of the variable (such as integer, string, or boolean) and assign a meaningful name to it. By doing so, the programmer is indicating how the variable should be interpreted and used in the program. This helps in organizing and managing the data effectively, as well as ensuring that the variable is used correctly throughout the program.

    Rate this question:

  • 3. 

    Which of the following is NOT a data type in Robot-C?

    • A.

      Integer

    • B.

      Floating Point Decimal

    • C.

      Value Assignment

    • D.

      String

    • E.

      Boolean

    Correct Answer
    C. Value Assignment
    Explanation
    The given options are different data types in Robot-C. Integer, Floating Point Decimal, String, and Boolean are all valid data types in Robot-C. However, "Value Assignment" is not a data type. It seems to be a concept or operation related to assigning values to variables in the programming language.

    Rate this question:

  • 4. 

    Which of the following accurately describes a Boolean data type?

    • A.

      True or False statement

    • B.

      A string of typed characters (including letters, numbers, and/or typed symbols)

    • C.

      A numeric value that includes a decimal

    • D.

      Positive and negative whole numbers including zero

    Correct Answer
    A. True or False statement
    Explanation
    A Boolean data type is a data type that can only have two possible values: true or false. It is used to represent logical values and is commonly used in programming to make decisions or control the flow of a program. Unlike other data types such as strings or numbers, a Boolean can only have these two specific values, making it a suitable choice for representing conditions or binary choices.

    Rate this question:

  • 5. 

    Which of the following code declares the data type “Hello World!”?

    • A.

      Int

    • B.

      Float

    • C.

      String

    • D.

      Bool

    Correct Answer
    C. String
    Explanation
    The correct answer is "string" because "Hello World!" is a sequence of characters, which is represented by the string data type in most programming languages. The other options (int, float, bool) are used for declaring numerical or boolean values, not for declaring strings.

    Rate this question:

  • 6. 

    Which of the following variables are NOT part of an Automatic Threshold calculation program?

    • A.

      Int darkValue;

    • B.

      Int sumValue;

    • C.

      Int lightValue;

    • D.

      Int lineValue;

    • E.

      Int thresholdValue;

    Correct Answer
    D. Int lineValue;
    Explanation
    The variable "int lineValue" is not part of an Automatic Threshold calculation program. The other variables "int darkValue", "int sumValue", "int lightValue", and "int thresholdValue" are all relevant to the calculation of the automatic threshold.

    Rate this question:

  • 7. 

    What is the “lastSeen” variable used for in the Line Counting program?

    • A.

      To prevent the robot from counting the same line more than once

    • B.

      To give the robot a reference point to begin counting

    • C.

      To allow the robot to count the previous lines

    • D.

      To compile the number of lines crossed

    Correct Answer
    A. To prevent the robot from counting the same line more than once
    Explanation
    The "lastSeen" variable is used in the Line Counting program to prevent the robot from counting the same line more than once. This variable keeps track of the last line that the robot counted, allowing it to compare the current line with the last seen line and determine whether it has already been counted. By using this variable, the robot ensures that it only counts each line once, avoiding duplications in the line count.

    Rate this question:

  • 8. 

    What keyword is used in Robot-C to begin the declaration of a function?

    • A.

      Task

    • B.

      Func

    • C.

      Main

    • D.

      Void

    Correct Answer
    D. Void
    Explanation
    In Robot-C, the keyword "void" is used to begin the declaration of a function. This keyword indicates that the function does not return any value.

    Rate this question:

  • 9. 

    What behavior would running the following code cause your robot to exhibit? 1     void specialFunction(int p) 2     { 3       motor[motorC] = p/2; 4       motor[motorB] = p/2; 5       wait1Msec(100*p); 6     } 7 8     task main() 9     { 10   specialFunction(50); 11   }

    • A.

      The robot would move forward for 1 second at 50% motor power

    • B.

      The robot would move backwards for 1 second at 25% motor power

    • C.

      The robot would move forward for 5 seconds at 50% motor power

    • D.

      The robot would move forward for 5 seconds at 25% motor power

    Correct Answer
    D. The robot would move forward for 5 seconds at 25% motor power
    Explanation
    The code defines a function called specialFunction that takes an integer parameter p. Inside the function, the motor power of motorC and motorB is set to half of p. Then, the program waits for 100 times p milliseconds. In the main task, the specialFunction is called with an argument of 50. Since the motor power is set to half of p, which is 25, and the program waits for 100 times p milliseconds, which is 5000 milliseconds or 5 seconds, the robot would move forward for 5 seconds at 25% motor power.

    Rate this question:

  • 10. 

    What line(s) in the following code would you have to change to make the robot go forward for 5 seconds at 50% motor power? 1     void specialFunction(int p) 2     {           3       motor[motorC] = p/2; 4       motor[motorB] = p/2; 5       wait1Msec(100*p); 6     } 7 8     task main() 9     { 10   specialFunction(50); 11   }

    • A.

      Lines 3, 4, and 5

    • B.

      Line 1

    • C.

      Line 5 and 10

    • D.

      Line 3, 4, and 10

    Correct Answer
    C. Line 5 and 10
    Explanation
    To make the robot go forward for 5 seconds at 50% motor power, we need to change line 5 and line 10. Line 5 sets a delay based on the input parameter p, so we need to change it to wait1Msec(5000) to wait for 5 seconds. Line 10 calls the specialFunction with an input of 50, so we need to change it to specialFunction(100) to set the motor power to 50% (since p/2 is used to set the motor power in line 3 and line 4).

    Rate this question:

  • 11. 

    Which of the following code declares the data type “43”?

    • A.

      Int

    • B.

      Float

    • C.

      String

    • D.

      Bool

    Correct Answer
    A. Int
    Explanation
    The correct answer is "int" because "int" is the data type used to declare whole numbers in programming languages. In this case, "int" would declare the data type for the value "43".

    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
  • Mar 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 04, 2009
    Quiz Created by
    Zmolls
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.