C Quiz – 101 | Question 1

Suppose that in a C program snippet, followings statements are used.





i) sizeof(int);
ii) sizeof(int*);
iii) sizeof(int**);


Assuming size of pointer is 4 bytes and size of int is also 4 bytes, pick the most correct answer from the given options.
(A) Only i) would compile successfully and it would return size as 4.
(B) i), ii) and iii) would compile successfully and size of each would be same i.e. 4
(C) i), ii) and iii) would compile successfully but the size of each would be different and would be decided at run time.
(D) ii) and iii) would result in compile error but i) would compile and result in size as 4.

Answer: (B)

Explanation: Size of all pointer types is same.

And whether it is a ‘pointer to char’ or ‘pointer to int’ or ‘pointer to pointer to int’, the size always remain same.

That’s why all i), ii) and iii) would compile successfully and would result in same size value of 4.

Quiz of this Question

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.