0
0
C++programming~10 mins

Built-in data types in C++ - Interactive Code Practice

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

Complete the code to declare an integer variable named age.

C++
int [1] = 25;
Drag options to blanks, or click blank then click option'
Aage
Bvalue
Cnumber
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using a keyword as a variable name.
Forgetting to declare the variable type.
2fill in blank
medium

Complete the code to declare a floating-point variable named price with value 19.99.

C++
float [1] = 19.99f;
Drag options to blanks, or click blank then click option'
Avalue
Bcost
Camount
Dprice
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer type for decimal numbers.
Missing the f suffix for float literals.
3fill in blank
hard

Fix the error in the code by choosing the correct data type for the variable isOpen.

C++
[1] isOpen = true;
Drag options to blanks, or click blank then click option'
Ainteger
Bstring
Cbool
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using string or float for boolean values.
Using integer which is not a valid C++ type.
4fill in blank
hard

Fill both blanks to declare a character variable named grade with value 'A'.

C++
char [1] = [2];
Drag options to blanks, or click blank then click option'
Agrade
B'A'
C"A"
Dletter
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes for characters (which makes it a string).
Using an incorrect variable name.
5fill in blank
hard

Fill both blanks to declare a double variable named distance with value 123.456.

C++
double [1] = [2];
Drag options to blanks, or click blank then click option'
Adistance
B123.456
C123.456f
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using float suffix f with double type.
Using an unrelated variable name.