Doubt in MCQ questions

Could you please explain the solution for MCQ 2, 3, 4, 6 , 7. i did not understand the approach.

can you plz share the questions as well

it will be great if you post separate doubt for each question or two question in one doubt

Q­2 which of the following statement(s) best refer to pointers?

A) Pointer arithmetic is permitted on pointers of any type.
B) A c pointer of type void can be used to directly examine or modify any object of any type
C) A c pointer knows the types of pointers and indirectly referenced data items at runtime

D) All of above

Q­3 How can dynamic array of pointers(to integers) of size 100 can be created using new in C++?
A) int *arr = new int *[100];
B) int **arr = new int *[100];

C) int *arr = new int [100];
D) int arr = new int [100];
Q­4 What is the problem with the following code #include<stdio.h> int main()
{

int *ptr = (int *)malloc(sizeof(int)); ptr = NULL;
free(ptr);

}
A) Dangling Pointer

B) Memory leak
C) The program may crash as free() is called for NULL pointer. D) Compiler Error

Q­6 What will be the output of the following program? #include using namespace std;

int main() {
int arr[]={0,1,2,3,4};

int i, ptr;
for(ptr= arr, i=0; ptr+i <= arr+4; ptr++, i++) cout<<
(ptr+i); return 0;

}
A) 01234 B) 024 C) 234 D) 12340

Q­7 In the piece of code, arr[ ][ ] is a 2­D array and assume that the contents of the 2­D array are already filled up. What is stored in the variable sum at the end of the code segment?
int arr[3][3];

int i, sum=0; i = 0; while(i<3) { sum += * ( * (arr+i)+(i++)); } printf(“sum:%d”, sum);

A) Sum of all elements in the matrix
B) Sum of alternate elements in the matrix
C) Sum of the elements along the principal diagonal D) None

what’s the problem in Question 2

only C is correct

A is incorrect because you can’t use pointer Arithmetic on a void pointer

B is obviously(if you know void pointers) incorrect

in question 3 B is Correct
there are only 2 valid statements B and C
C is for creating array of integers
and B is for creating array of pointers (or you can also use this for 2D array declaration)

for other can you plz post separate doubt?

Sure. Thanks for clarifying

okay
in those doubts just mention question no
i will read question from here

so that things don’t take much time

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.