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 2On 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)…

  1. A.

    4 4

  2. B.

    2 2

  3. C.

    4 2

  4. 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.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…