Robot C - Variables

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 Zmolls
Z
Zmolls
Community Contributor
Quizzes Created: 7 | Total Attempts: 16,275
| Attempts: 239 | Questions: 11
Please wait...
Question 1 / 11
0 %
0/100
Score 0/100
1. When a programmer “declares” a variable, they…

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.

Submit
Please wait...
About This Quiz
Languages Quizzes & Trivia

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

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

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.

Submit
3. Which of the following accurately describes a Boolean data type?

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.

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

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.

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

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".

Submit
6. The output of a sensor is always in the form of a…

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.

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

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.

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

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.

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

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.

Submit
10. 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   }

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.

Submit
11. 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   }

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).

Submit
View My Results

Quiz Review Timeline (Updated): Mar 17, 2023 +

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
Cancel
  • All
    All (11)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
When a programmer “declares” a variable, they…
Which of ...
Which of the following accurately describes a Boolean data type?
Which of the following is NOT a data type in Robot-C?
Which of the following code declares the data type “43”?
The output of a sensor is always in the form of a…
What is ...
Which of ...
What ...
What ...
What ...
Alert!

Advertisement