Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a variable for storing the output signal.
Simulink
double [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a data type instead of a variable name.
Choosing a variable name that does not match the output.
✗ Incorrect
The variable output_signal is declared as a double to store the output value.
2fill in blank
mediumComplete the code to assign the input value to the variable.
Simulink
[1] = input_signal; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the variable to itself.
Using the input variable on the left side.
✗ Incorrect
The variable output_signal receives the value from input_signal.
3fill in blank
hardFix the error in the function call to update the output.
Simulink
updateOutput([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the input variable instead of the output.
Using an undefined variable.
✗ Incorrect
The function updateOutput should be called with the output variable output_signal.
4fill in blank
hardFill both blanks to create a for loop that iterates over 10 elements and sums them.
Simulink
double sum = 0; for (int [1] = 0; [2] < 10; [1]++) { sum += data[[1]]; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the loop header.
Using a variable name not declared in the loop.
✗ Incorrect
The loop variable i is used consistently to iterate from 0 to 9.
5fill in blank
hardFill all three blanks to create a dictionary-like structure in C using structs and initialize it.
Simulink
typedef struct {
char* [1];
int [2];
} [3];
[3] data[] = { {"speed", 100}, {"power", 200} }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up field names.
Using inconsistent struct names.
✗ Incorrect
The struct Parameter has fields name and value to hold key-value pairs.