Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print "Hello, World!" in C.
C
#include <stdio.h> int main() { [1]("Hello, World!\n"); return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'print' instead of 'printf'.
Using 'cout' which is from C++.
✗ Incorrect
The printf function is used in C to print text to the screen.
2fill in blank
mediumComplete the code to declare an integer variable named 'age' in C.
C
[1] age = 25;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'var' which is not valid in C.
Using 'integer' which is not a C keyword.
✗ Incorrect
In C, int is used to declare integer variables.
3fill in blank
hardFix the error in the code to correctly declare a character variable named 'letter'.
C
char [1] = 'A';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting variable name with a digit.
Using reserved keywords as variable names.
✗ Incorrect
Variable names cannot start with a number. 'letter' is a valid name.
4fill in blank
hardFill both blanks to create a for loop that counts from 0 to 4 in C.
C
for (int i = [1]; i [2] 5; i++) { printf("%d\n", i); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' causes the loop to run one extra time.
Starting the loop at 1 instead of 0.
✗ Incorrect
The loop starts at 0 and continues while i is less than 5.
5fill in blank
hardFill all three blanks to declare and initialize an array of 3 integers in C.
C
int [1][[2]] = [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid variable names.
Not using curly braces to initialize the array.
✗ Incorrect
This declares an integer array named 'numbers' with 3 elements initialized to 1, 2, and 3.