0
0
Cprogramming~10 mins

Why variables are needed in C - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an integer variable named age.

C
int [1];
Drag options to blanks, or click blank then click option'
Aage
B5
Cmain
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a name.
Using a reserved word like main.
2fill in blank
medium

Complete 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'
A=
B!=
C+=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of = for assignment.
Using != which means 'not equal'.
3fill in blank
hard

Fix 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'
Ainteger
Bfloat
Cint
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer instead of int.
Using float or char which are different types.
4fill in blank
hard

Fill 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'
Afloat
Bheight
Cint
Dweight
Attempts:
3 left
💡 Hint
Common Mistakes
Using int for decimal values.
Using wrong variable names.
5fill in blank
hard

Fill 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'
Acount
Btotal
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in declaration and print.
Forgetting to declare the variable before use.