What is the output of the following code? void main () { char far * farther, * farthest; printf(“%d..%d”, sizeof(farther), sizeof(farthest)); }

What is the output of the following code? void main () { char far * farther, * farthest; printf(“%d..%d”, sizeof(farther), sizeof(farthest)); } Correct Answer 4..2

char pointer:

A pointer to char points to single char. sizeof() operator is used to find the size of a variable or pointer in the programming language. Char pointer size is 2 bytes (machine-dependent).

far pointer:

This pointer is used to access the complete memory of RAM. Size of the far pointer is 4 bytes of 32 bit.

In an Intel 8086, as well as in later processors running 16-bit code, a far pointer has two parts: a 16-bit segment value and a 16-bit offset value.

Code:

void main ()
{
char far * farther, * farthest;
printf(“%d..%d”, sizeof(farther),
sizeof(farthest));
}

Farther is a far pointer in this. So, sizeof(farther) will return 4 bytes.

sizeof(farthest) will return 2 bytes. As it is only a char pointer.

Important Points:

The answer will vary depending upon the system.

This ambiguous  question

Related Questions

Determine output:
#include void main(){ char *p = NULL; char *q = 0; if(p) printf(" p "); else printf("nullp"); if(q) printf("q"); else printf(" nullq");}