1.
The
output of a sensor is always in the form of a…
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.
2.
When a
programmer “declares” a variable, they…
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.
3.
Which of
the following is NOT a data type in Robot-C?
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.
4.
Which of
the following accurately describes a Boolean data type?
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.
5.
Which of
the following code declares the data type “Hello World!”?
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.
6.
Which of
the following variables are NOT part of an Automatic Threshold calculation
program?
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.
7.
What is
the “lastSeen” variable used for in the Line Counting program?
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.
8.
What
keyword is used in Robot-C to begin the declaration of a function?
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.
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 }
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.
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 }
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).
11.
Which of
the following code declares the data type “43”?
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".