Home »
MCQs »
C++ MCQs
Which of the following is a valid way to allocate dynamic memory for an integer variable?
162 . Which of the following is a valid way to allocate dynamic memory for an integer variable?
- int *ptr = new int(111);
- int *ptr = NULL;ptr = new int; *ptr=111;
- int *ptr;ptr = new int; *ptr=111;
- All the above
Answer: D) All the above
Explanation:
All the given options are valid to allocate dynamic memory for an integer variable.