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?

  1. int *ptr = new int(111);
  2. int *ptr = NULL;ptr = new int; *ptr=111;
  3. int *ptr;ptr = new int; *ptr=111;
  4. All the above

Answer: D) All the above

Explanation:

All the given options are valid to allocate dynamic memory for an integer variable.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.