0
0
C++programming~10 mins

Type modifiers 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 a constant integer variable named num with value 10.

C++
const [1] num = 10;
Drag options to blanks, or click blank then click option'
Aint
Bfloat
Cchar
Ddouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using a floating-point type like float or double instead of int.
Forgetting to add const before the type.
2fill in blank
medium

Complete the code to declare a pointer to a constant character named ptr.

C++
const char* [1];
Drag options to blanks, or click blank then click option'
AcharPtr
BpChar
Cpointer
Dptr
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name different from ptr as asked.
Placing the asterisk incorrectly.
3fill in blank
hard

Fix the error in the code by completing the type modifier to declare a volatile integer variable named counter.

C++
[1] int counter;
Drag options to blanks, or click blank then click option'
Aconstant
Bmutable
Cvolatile
Dstatic
Attempts:
3 left
💡 Hint
Common Mistakes
Using constant instead of volatile.
Using static which has a different meaning.
4fill in blank
hard

Fill both blanks to declare a pointer to a volatile integer named p.

C++
[1] int [2] p;
Drag options to blanks, or click blank then click option'
Avolatile
B*
C&
Dconst
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * for pointer declaration.
Placing const instead of volatile.
5fill in blank
hard

Fill all three blanks to declare a constant pointer to a constant integer named ptr.

C++
[1] int [2] [3] ptr;
Drag options to blanks, or click blank then click option'
Aconst
B*
Dvolatile
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the second const to make the pointer constant.
Using volatile instead of const.