0
0
C++programming~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 library.

C++
#include [1]
Drag options to blanks, or click blank then click option'
A<vector>
B<stdio.h>
C<iostream>
D<string>
Attempts:
3 left
💡 Hint
Common Mistakes
Using which is a C library, not standard for C++ input/output.
Forgetting the angle brackets around the library name.
2fill in blank
medium

Complete the code to start the main function.

C++
int [1]() {
    return 0;
}
Drag options to blanks, or click blank then click option'
Amain
Bstart
Cbegin
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using other function names like start or begin which are not recognized as entry points.
Omitting the parentheses after the function name.
3fill in blank
hard

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

C++
#include <iostream>

int main() {
    std::cout [1] "Hello, World!" << std::endl;
    return 0;
}
Drag options to blanks, or click blank then click option'
A>>
B<<
C+
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using the extraction operator >> which is for input.
Using assignment or addition operators which are incorrect here.
4fill in blank
hard

Fill both blanks to declare and initialize an integer variable named count with value 10.

C++
[1] [2] = 10;
Drag options to blanks, or click blank then click option'
Aint
Bcount
Cfloat
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using float instead of int for an integer variable.
Using invalid variable names or reserved words.
5fill in blank
hard

Fill all three blanks to create a simple for loop that prints numbers 1 to 5.

C++
for (int [1] = 1; [2] <= 5; [3]++) {
    std::cout << i << std::endl;
}
Drag options to blanks, or click blank then click option'
Ai
Dj
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in different parts of the loop.
Using a variable name not declared in the loop.