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 'echo' which is not a C function.
Using 'cout' which is from C++.
✗ Incorrect
The printf function is used in C to print text to the console.
2fill in blank
mediumComplete the code to declare an integer variable named 'count' and assign it the value 10.
C
int [1] = 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'count'.
✗ Incorrect
The variable name should be 'count' as specified.
3fill in blank
hardFix the error in the code to correctly compare if 'a' is greater than 'b'.
C
if (a [1] b) { printf("a is greater\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which is assignment, not comparison.
Using '==' which checks equality, not greater than.
✗ Incorrect
The '>' operator checks if 'a' is greater than 'b'.
4fill in blank
hardFill both blanks to create a for loop that counts from 0 to 4.
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
Starting at 1 instead of 0.
Using 'i > 5' which would never run.
✗ Incorrect
The loop starts at 0 and continues while i is less than 5.
5fill in blank
hardFill all three blanks to declare a function named 'add' that takes two integers and returns their sum.
C
int [1](int [2], int [3]) { return a + b; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different parameter names than 'a' and 'b'.
Naming the function something other than 'add'.
✗ Incorrect
The function name is 'add' and parameters are 'a' and 'b'.