1) Which operator is used to get the "content of a
variable pointed to by a pointer"?
1.Dot Operator (.)
2.Address of Operator (&)
3.Indirection or De-reference Operator (*)
4.Arrow Operator (→)
Answer & Explanation:
Correct answer: 3
Indirection or De-reference Operator (*)
2) What will be the type of a pointer, which is pointing to
an integer variable?
1.int *
2.long int *
3.char *
4.unsigned *
Answer & Explanation:
Correct answer: 1
int *
3) If ptr is a pointer to one dimensional array, which
statement will return the value of 3rd element?
1.(ptr+3)
2.*(ptr+3)
3.(&ptr+3)
4.*ptr+3
Answer & Explanation:
Correct answer: 2
*(ptr+3)
int* ptr1,ptr2;
What is the type of ptr2 here?
1.int * (Integer pointer)
2.void
3.void * (void pointer)
4.int (integer)
Answer & Explanation:
Correct answer: 2
int (integer)
int ptr2;
Thus, ptr is not int*, it is int type variable.
5) What will be the correct way to declare two integer
pointers using single line declaration?
1.int *ptr1,*ptr2;
2.int* ptr1,ptr2;
3.int * ptr1, ptr2;
4.All of the above
Answer & Explanation:
Correct answer: 1
int *ptr1,*ptr2;
6) Consider the following statement:
int arr[5],*ptr;
How to initialize ptr with the address of array arr?
1.ptr = arr;
2.ptr = &arr[0];
3.ptr = &arr;
4.Both 1) and 2)
Answer & Explanation:
Correct answer: 4
Both 1 and 2