Assume int is 4 bytes, char is 1 byte and float is 4 bytes. Also, assume that pointer size is 4 bytes (i.e. typical case)
char *pChar;
int *pInt;
float *pFloat;
sizeof(pChar);
sizeof(pInt);
sizeof(pFloat);
What’s the size returned for each of sizeof() operator?
A) 4 4 4
1 4 4
C) 1 4 8
D) None of the above
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.
No comments:
Post a Comment