Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a floating point variable.
Embedded C
float [1] = 3.14f;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer-like variable names for floats.
✗ Incorrect
The variable name pi is appropriate for a floating point value representing 3.14.
2fill in blank
mediumComplete the code to perform floating point addition.
Embedded C
float result = [1] + 2.5f;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using integers without 'f' suffix for float operations.
✗ Incorrect
Use a floating point number like 3.0f to add with another float.
3fill in blank
hardFix the error in the floating point division.
Embedded C
float division = 5 / [1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer divisor causing integer division.
✗ Incorrect
Use a floating point divisor like 2.0f to get a floating point result.
4fill in blank
hardFill both blanks to create a float array and initialize it.
Embedded C
float [1][3] = {1.0f, [2], 3.0f};
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer literals instead of float literals in initialization.
✗ Incorrect
The array name values is descriptive, and 2.0f is a float value to initialize the second element.
5fill in blank
hardFill all three blanks to compute the average of three floats.
Embedded C
float average = ([1] + [2] + [3]) / 3.0f;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer variables or missing one of the variables in the sum.
✗ Incorrect
Use the three float variables val1, val2, and val3 to calculate the average.