logo

CuriousTab

CuriousTab

Discussion


Home C Programming Declarations and Initializations See What Others Are Saying!
  • Question
  • What is the output of the program in Turbo C (in DOS 16-bit OS)?
    #include<stdio.h>
    int main()
    {
        char *s1;
        char far *s2;
        char huge *s3;
        printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3));
        return 0;
    }
    


  • Options
  • A. 2, 4, 6
  • B. 4, 4, 2
  • C. 2, 4, 4
  • D. 2, 2, 2

  • Correct Answer
  • 2, 4, 4 

    Explanation
    Any pointer size is 2 bytes. (only 16-bit offset)
    So, char *s1 = 2 bytes.
    So, char far *s2; = 4 bytes.
    So, char huge *s3; = 4 bytes.
    A far, huge pointer has two parts: a 16-bit segment value and a 16-bit offset value.

    Since C is a compiler dependent language, it may give different output in other platforms. The above program works fine in Windows (TurboC), but error in Linux (GCC Compiler).


    More questions

    • 1. By default structure variable will be of auto storage class

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 2. Bitwise can be used to reverse a sign of a number.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 3. Is it necessary that in a function which accepts variable argument list there should be at least be one fixed argument?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 4. Bitwise can be used to generate a random number.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 5. A function that receives variable number of arguments should use va_arg() to extract the last argument from the variable argument list.

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. Bitwise & can be used to check if more than one bit in a number is on.

    • Options
    • A. True
    • B. False
    • Discuss
    • 7. The preprocessor can trap simple errors like missing declarations, nested comments or mismatch of braces.

    • Options
    • A. True
    • B. False
    • Discuss
    • 8. It is necessary that a header files should have a .h extension?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 9. Bitwise | can be used to set multiple bits in number.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 10. Bitwise & can be used to check if a bit in number is set or not.

    • Options
    • A. True
    • B. False
    • Discuss


    Comments

    There are no comments.

Enter a new Comment