Examveda

Determine Output:
void main()
{
      char far *farther, *farthest;
      printf("%d..%d", sizeof(farther), sizeof(farthest));
}

A. 4..2

B. 2..2

C. 4..4

D. 2..4

Answer: Option C

Solution (By Examveda Team)

In the given C program code snippet:

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


The sizeof operator is used to determine the size, in bytes, of a variable or data type.

1. **farther** and **farthest** are both pointers of type **char***. In C, the size of a pointer is typically **4 bytes** on a 32-bit system or **8 bytes** on a 64-bit system. Assuming a standard 32-bit architecture, the size of both pointers would be **4 bytes**. 2. Therefore, the output of the printf function will be: - sizeof(farther) = 4 - sizeof(farthest) = 4

The printf statement prints these two sizes, resulting in the output **"4..4"**.

Hence, the correct answer is **Option C: 4..4**.

This Question Belongs to C Program >> Pointer

Join The Discussion

Comments (17)

  1. Challa Mahesh
    Challa Mahesh:
    10 months ago

    What difference it would make between normal pointer and far pointer?

  2. Challa Mahesh
    Challa Mahesh:
    10 months ago

    It should look like below right?
    char far,*farther,*farthest;

  3. Challa Mahesh
    Challa Mahesh:
    10 months ago

    There is comma missing between far and *farther.
    Is it valid way of declaring?

  4. Shubham Patra
    Shubham Patra:
    2 years ago

    It depends on the compiler.
    If you are using a 32-bit system, then it will be 4 bytes, but if you are using a 64-bit system, then it will be 8 bytes.
    So the answer should be 4-4, not 4-2.

  5. Hrithik Sharma
    Hrithik Sharma:
    3 years ago

    at any case, size of pointer variable = sizeof(unsigned int). because pointer variable always store address which is nothing but unsigned int.

  6. CHUNCHE GOWDA
    CHUNCHE GOWDA:
    4 years ago

    It depends on compiler that we are using,if our machine is 64bit then pointer is 8byte. if it is 32bit then it is 4 byte.
    In this case we are trying to print size of pointer not *ptr(i.e char pointer).

  7. Vivek Sharma
    Vivek Sharma:
    4 years ago

    This is a DOS-only program, it won't work in GCC or other modern compilers, far pointers are different types of pointers like near pointer and huge pointer.

  8. Adam Dont
    Adam Dont:
    4 years ago

    the answer should be 4 4

  9. Asst. Prof.
    Asst. Prof.:
    4 years ago

    correct answer is 2..2(or 4..4 depending on compiler you are using ). Because you are printing sizeof(farther) and sizeof(farthest), both are char pointers.

  10. Prachi Choudhary
    Prachi Choudhary:
    5 years ago

    Why ans B is right

  11. Swati Varma
    Swati Varma:
    5 years ago

    your solution is wrong

  12. Deepak Kumar
    Deepak Kumar:
    7 years ago

    Please explain how ,it is 4,2
    If we see the the concept of pointer ,pointer does not depend on datatype ,its depend on system

  13. Mukul Aggarwal
    Mukul Aggarwal:
    7 years ago

    pls explain anyone as
    according to me its 2,2

  14. Minakshi Shukla
    Minakshi Shukla:
    8 years ago

    Acording to me it shoud be 4 4 bcz pointer size is same always and depends upon int size of systm then it is 4 2 what is far plz explain

  15. Arunkumar C
    Arunkumar C:
    8 years ago

    pls explain detail...
    how pointer size is 2 ?

  16. Manju Kumar
    Manju Kumar:
    9 years ago

    plz detail explanation

  17. Archit Gupta
    Archit Gupta:
    9 years ago

    the answer should be 4...4 because pointer stores address of a variable which is of integer type and points the value of type of its datatype.

Related Questions on Pointer