Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an external variable.
C
extern int [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name instead of a variable name.
Trying to declare a keyword as a variable.
✗ Incorrect
The keyword extern declares a variable defined in another file or scope. Here, count is the external variable name.
2fill in blank
mediumComplete the code to define the external variable declared elsewhere.
C
int [1] = 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
extern keyword when defining the variable.Using a different variable name than declared.
✗ Incorrect
The variable count is defined here with an initial value. It matches the external declaration.
3fill in blank
hardFix the error in the code to correctly use the external variable.
C
extern int [1]; void printCount() { printf("Count is %d\n", [1]); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names in declaration and usage.
Using function names instead of variable names.
✗ Incorrect
The variable count must be used consistently as the external variable name.
4fill in blank
hardFill both blanks to declare and initialize an external variable correctly.
C
extern [1] [2]; // Defined in another file
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing data type and variable name order.
Using a float type when the variable is integer.
✗ Incorrect
The external variable count is declared as type int.
5fill in blank
hardFill all three blanks to define and use an external variable properly.
C
int [1] = 5; extern int [2]; void display() { printf("Value: %d\n", [3]); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for definition and external declaration.
Mismatching variable names in usage.
✗ Incorrect
The variable total is defined, count is declared external and used in the function.