in Programming in C retagged by
547 views
0 votes
0 votes
Which of the following is/are true regarding the following code snippet?

1:int *p;

2:p = &q;

 

A)*p gives faster retrieval of information than q.

B)The size of p is same as size of int.

C)Only statement 2 gives an error.

D)In statement 1, * is used as a dereferencing operator.
in Programming in C retagged by
547 views

8 Comments

@Aditya_  @Abhrajyoti00

pls check this also!

0
0
(A) This should be False.

(B) False. Size of p is equal to the size of address, which may or may not be equal to size of int.

(C) Depends on type of q, if q is int then no error, if q is not int then error (or warning). Data given is not enough to state True or False.

(D) False. * in "int *p;" is not dereferencing operator, it is just to tell compiler that variable p is of type "int *".

This is not a good question.
1
1

The answer given is A and C

but all the reasons that you have given seems correct.

yes very ambiguous question..

 

0
0

This is the answer provided by them

(A)Pointers are faster. \therefore True

(B)The size of pointer is same as the logical address of the memory, size pointer saves the address not the value of operand. \ False.

(C)Only statement 2 gives an Address arithmetic error, since the pointer is not declared. \therefore True.

(D)In statement 1 * is used for pointer declaration not as dereferencing operator. \therefore false.

0
0

@Pranavpurkar Ask them why (A) is True, and share what they tell you with us, I want to know what they say.

But according to me it should be False.

0
0

I just asked them and they provided a video solution  mentioning following reasons for all the options 

  1. TRUE because pointers have direct address of the respective stored variable in the memory so the retrieval is always faster.
  2.  FALSE because it not depends on what is the data type of pointer rather it depends on what is the data type of the variable to which it is pointing to and also on the architecture of the machine.
  3. TRUE , here they treated statement 2 separately and said that we can’t just store address of some variable in another variable if we assume it to be pointer then first it needs to be declared.
  4. FALSE , here * is not the dereferencing operator rather a referencing operator and it is just to declare that variable P is a pointer of type int.
0
0

@Pranavpurkar For your mental and technical health please avoid such questions and even more the explanations. 

1
1

yes sir!

0
0

Please log in or register to answer this question.

Related questions

0 votes
0 votes
2 answers
2