Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer variable named age.
C
int [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a name.
Using a reserved word like
main.✗ Incorrect
Variables store data. Here, age is the name of the variable.
2fill in blank
mediumComplete the code to assign the value 10 to the variable count.
C
count [1] 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
== instead of = for assignment.Using
!= which means 'not equal'.✗ Incorrect
The single equals sign = assigns a value to a variable.
3fill in blank
hardFix the error in the code to declare a variable named score of type integer.
C
[1] score; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
integer instead of int.Using
float or char which are different types.✗ Incorrect
In C, int is the correct keyword for integer variables.
4fill in blank
hardFill both blanks to declare a variable height of type float and assign it the value 1.75.
C
[1] [2] = 1.75;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
int for decimal values.Using wrong variable names.
✗ Incorrect
float declares a decimal number variable, and height is the variable name.
5fill in blank
hardFill all three blanks to declare an integer variable total, assign 100 to it, and then print it using printf.
C
int [1]; [2] = 100; printf("%d\n", [3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in declaration and print.
Forgetting to declare the variable before use.
✗ Incorrect
The variable total is declared, assigned, and printed. The same name is used consistently.