0
0
C++programming~10 mins

What is C++ - Interactive Quiz & Practice

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

Complete the code to print "Hello, C++!" to the console.

C++
#include <iostream>

int main() {
    std::cout << [1] << std::endl;
    return 0;
}
Drag options to blanks, or click blank then click option'
A"Hello, C++!"
BHello, C++!
Ccout << "Hello, C++!"
Dstd::endl
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the double quotes around the text.
Trying to print without std::cout.
2fill in blank
medium

Complete the code to declare an integer variable named 'age' with value 25.

C++
int [1] = 25;
Drag options to blanks, or click blank then click option'
Avalue
Bnumber
Cage
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong variable name.
Trying to declare type twice.
3fill in blank
hard

Fix the error in the code to correctly return 0 from main.

C++
int main() {
    return [1];
}
Drag options to blanks, or click blank then click option'
A0
Bone
C"0"
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a string instead of an integer.
Returning a non-zero value.
4fill in blank
hard

Fill both blanks to declare a float variable 'pi' with value 3.14.

C++
[1] [2] = 3.14;
Drag options to blanks, or click blank then click option'
Afloat
Bdouble
Cpi
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using int type for decimal values.
Wrong variable name.
5fill in blank
hard

Fill all three blanks to create a simple if statement that prints "Yes" if x is greater than 10.

C++
#include <iostream>

int main() {
    int x = 15;
    if (x [1] [2]) {
        std::cout << [3] << std::endl;
    }
    return 0;
}
Drag options to blanks, or click blank then click option'
A<
B10
C"Yes"
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operator.
Forgetting quotes around the string.