What will be output of following program for a 16-bit machine having pointer…
What will be output of following program for a 16-bit machine having pointer size of 2B?
#include<stdio.h>
#include<string.h>
int main(){
char *p,*q;
printf("%d %d",sizeof(p),sizeof(q));
return 0;
}
Answer: B. 2 2 — On a 16-bit machine, the size of any pointer (whether char*, int*, or float*) is 2 bytes. Since both p and q are character pointers, sizeof(p) and sizeof(q)…
- A.
4 4
- B.
2 2
- C.
4 2
- D.
2 4
Attempted by 405 students.
Show answer & explanation
Correct answer: B
On a 16-bit machine, the size of any pointer (whether char*, int*, or float*) is 2 bytes. Since both p and q are character pointers, sizeof(p) and sizeof(q) will each give 2. So the output is 2 2.
Loading lesson…