Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print a message to the screen.
C
#include <stdio.h> int main() { printf([1]); return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the double quotes around the string.
Using single quotes instead of double quotes.
✗ Incorrect
The printf function requires a string in double quotes to print text.
2fill in blank
mediumComplete the code to read an integer from the user.
C
#include <stdio.h> int main() { int number; scanf([1], &number); printf("You entered: %d\n", number); return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong format specifier like %f or %s.
Not using the & operator before the variable.
✗ Incorrect
The scanf function uses %d to read an integer value.
3fill in blank
hardFix the error in the code to correctly read and print a float value.
C
#include <stdio.h> int main() { float value; scanf([1], &value); printf("Value: %f\n", value); return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using %d instead of %f for floats.
Not using & before the variable name.
✗ Incorrect
Use %f in scanf to read a float value.
4fill in blank
hardFill both blanks to create a program that reads a character and prints it.
C
#include <stdio.h> int main() { char ch; scanf([1], &ch); printf([2], ch); return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong format specifiers like %d or %f.
Not matching format specifiers between scanf and printf.
✗ Incorrect
Use %c in scanf to read a character and in printf to print it.
5fill in blank
hardFill all three blanks to create a program that reads two integers and prints their sum.
C
#include <stdio.h> int main() { int a, b; scanf([1], &a); scanf([2], &b); printf([3], a + b); return 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong format specifiers like %f or %c.
Forgetting to use & before variables in scanf.
✗ Incorrect
Use %d to read integers and print their sum with a message.