0
0
Cprogramming~10 mins

Structure of a C program - Interactive Code Practice

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

Complete the code to include the standard input-output header.

C
#include [1]
Drag options to blanks, or click blank then click option'
A<string.h>
B<stdlib.h>
C"myheader.h"
D<stdio.h>
Attempts:
3 left
💡 Hint
Common Mistakes
Using instead of for input-output functions.
Forgetting the angle brackets around the header name.
2fill in blank
medium

Complete the code to define the main function that returns an integer.

C
[1] main() {
    return 0;
}
Drag options to blanks, or click blank then click option'
Avoid
Bint
Cfloat
Dchar
Attempts:
3 left
💡 Hint
Common Mistakes
Using void as the return type for main.
Using data types like float or char for main.
3fill in blank
hard

Fix the error in the code by completing the statement to print "Hello, World!".

C
#include <stdio.h>

int main() {
    [1]("Hello, World!\n");
    return 0;
}
Drag options to blanks, or click blank then click option'
Aprintf
Bprintln
Cprint
Dcout
Attempts:
3 left
💡 Hint
Common Mistakes
Using print or println which are not valid in C.
Using cout which is from C++.
4fill in blank
hard

Fill both blanks to declare a variable and assign it a value inside main.

C
int main() {
    [1] [2] = 10;
    return 0;
}
Drag options to blanks, or click blank then click option'
Aint
Bfloat
Cnumber
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using float when the value is an integer.
Using invalid variable names like number which is not declared.
5fill in blank
hard

Fill all three blanks to complete a simple C program that prints a variable's value.

C
#include <stdio.h>

[1] main() {
    [2] [3] = 5;
    printf("Value: %d\n", [3]);
    return 0;
}
Drag options to blanks, or click blank then click option'
Aint
Cnum
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in declaration and print statement.
Using void as return type for main.