Home / CSE MCQs / C-MCQs :: Data Types

CSE MCQs :: C-MCQs

  1. Comment on the output of this C code?

    int main()
    {
    int a[5] = {1, 2, 3, 4, 5};
    int i;
    for (i = 0; i < 5; i++)
    if ((char)a[i] == '5')
    printf("%d\n", a[i]);
    else
    printf("FAIL\n");
    }
  2. A.
    The compiler will flag an error
    B.
    Program will compile and print the output 5
    C.
    Program will compile and print the ASCII value of 5
    D.
    Program will compile and print FAIL for 5 times

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. The format identifier '%i' is also used for _____ data type?
  4. A.
    char
    B.
    int
    C.
    float
    D.
    double

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which data type is most suitable for storing a number 65000 in a 32-bit system?
  6. A.
    short
    B.
    int
    C.
    long
    D.
    double

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following is a User-defined data type?
  8. A.
    typedef int Boolean;
    B.
    typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
    C.
    struct {char name[10], int age};
    D.
    All of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the size of an int data type?
  10. A.
    4 Bytes
    B.
    8 Bytes
    C.
    Depends on the system/compiler
    D.
    Cannot be determined.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the output of this C code?

    int main()
    {
    char chr;
    chr = 128;
    printf("%d\n", chr);
    return 0;
    }
  12. A.
    128
    B.
    - 128
    C.
    Depends on the compiler
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Comment on the output of this C code?

    int main()
    {
    char c;
    int i = 0;
    FILE *file;
    file = fopen("test.txt", "w+");
    fprintf(file, "%c", 'a');
    fprintf(file, "%c", -1);
    fprintf(file, "%c", 'b');
    fclose(file);
    file = fopen("test.txt", "r");
    while ((c = fgetc(file)) != -1)
    printf("%c", c);
    return 0;
    }
  14. A.
    a
    B.
    Infinite loop
    C.
    Depends on what fgetc returns
    D.
    Depends on the compiler

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What is short int in C programming?
  16. A.
    Basic data type of C
    B.
    Qualifier
    C.
    short is the qualifier and int is the basic datatype
    D.
    All of the mentioned.

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Comment on the output of this C code?

    int main()
    {
    float f1 = 0.1;
    if (f1 == 0.1)
    printf("equal\n");
    else
    printf("not equal\n");
    }
  18. A.
    equal
    B.
    not equal
    C.
    Output depends on compiler
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Comment on the output of this C code?

    int main()
    {
    float f1 = 0.1;
    if (f1 == 0.1f)
    printf("equal\n");
    else
    printf("not equal\n");
    }
  20. A.
    equal
    B.
    not equal
    C.
    Output depends on compiler
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum