0
0
Cprogramming~10 mins

Use cases - Interactive Code Practice

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

Complete 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'
Aecho
Bprintf
Cprint
Dcout
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++.
2fill in blank
medium

Complete 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'
Acount
Bnumber
Cvalue
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'count'.
3fill in blank
hard

Fix 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'
A>
B==
C=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which is assignment, not comparison.
Using '==' which checks equality, not greater than.
4fill in blank
hard

Fill 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'
A0
B<
C>
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Starting at 1 instead of 0.
Using 'i > 5' which would never run.
5fill in blank
hard

Fill 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'
Aadd
Ba
Cb
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using different parameter names than 'a' and 'b'.
Naming the function something other than 'add'.