Given the declaration: int *p; the statement: p = new int[50]; dynamically alloc
ID: 3796638 • Letter: G
Question
Given the declaration: int *p; the statement: p = new int[50]; dynamically allocates an array of 50 components of type int, and p contains the base address of the array. True False Giving the following declarations, which of the following statements are valid? inti, *pi; doubled, *pd; i= *pi=&i; pd= pi=&i; What is the return type of the function with prototype: "int func(char x, float v, double t);" char int float double Which reference modifier is used to define reference variable? & $ # none of the mentioned The stake can be used to allocate the memory dynamically. True FalseExplanation / Answer
1. option A - True - int *p = new int[50] creates an array of 50 int variables and p will point to p[0]
2. option D - pi = &i . pi will store the address of i. All other declarations have compiler error
3. Option B - int - In the function prototype, the data type that is written before the function name is the return type.
4. Option A - & - ampersand is the syntax qualifier to be used for referencing variables.
5. Option B - false - new operator is used to allocate memory dynamically.
Question 2 :
delete operator is used for deallocating memory for heap-dynamic variables and pointer variables.
For example:
int *p = new int[50]; //creating pointer with memory of 50 int type
delete p; // de-allocating memory of 50 int type
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.