Home / CSE MCQs / C-MCQs :: C Operators

CSE MCQs :: C-MCQs

  1. What is the output of this C code?

        void main()
        {
            int x = 4;
            int *p = &x;
            int *k = p++;
            int r = p - k;
            printf("%d", r);
        }
  2. A.
    4
    B.
    8
    C.
    1
    D.
    Run time error

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What is the output of this C code?

        void main()
        {
            int a = 5, b = -7, c = 0, d;
            d = ++a && ++b || ++c;
            printf("\n%d%d%d%d", a, b, c, d);
        }
  4. A.
    6  -6  0  0
    B.
    6  -5  0  1
    C.
    -6  -6  0  1
    D.
    6  -6  0  1

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is the output of this C code?

        void main()
        {
            int a = -5;
            int k = (a++, ++a);
            printf("%d\n", k);
        }
  6. A.
    -3
    B.
    -5
    C.
    4
    D.
    Undefined

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the output of this C code?

        int main()
        {
            int x = 2;
            x = x << 1;
            printf("%d\n", x);
        }
  8. A.
    4
    B.
    1
    C.
    Depends on the compiler
    D.
    Depends on the endianness of the machine

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of this C code?

        int main()
        {
            int x = -2;
            x = x >> 1;
            printf("%d\n", x);
        }
  10. A.
    1
    B.
    -1
    C.
    2 ^ 31 "“ 1 considering int to be 4 bytes
    D.
    Either (b) or (c)

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the output of this C code?

        int main()
        {
            if (~0 == 1)
                printf("yes\n");
            else
                printf("no\n");
        }
  12. A.
    Yes
    B.
    No
    C.
    Compile time error
    D.
    Undefined

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of this C code?

        int main()
        {
            int x = -2;
            if (!0 == 1)
                printf("yes\n");
            else
                printf("no\n");
        }
  14. A.
    Yes
    B.
    No
    C.
    Run time error
    D.
    Undefined

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What is the output of this C code?

        int main()
        {
            int y = 1;
            if (y & (y = 2))
                printf("true %d\n");
            else
                printf("false %d\n");
     
        }
  16. A.
    true 2
    B.
    false 2
    C.
    Either option a or option b
    D.
    true 1

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the difference between the following 2 codes?

    //Program 1
        int main()
        {
            int d, a = 1, b = 2;
            d =  a++ + ++b;
            printf("%d %d %d", d, a, b);
        }


     //Program 2
        int main()
        {
            int d, a = 1, b = 2;
            d =  a++ + ++b;
            printf("%d %d %d", d, a, b);
        }
  18. A.
    No difference as space doesn't make any difference, values of a, b, d are same in both the case
    B.
    No difference as space doesn't make any difference, values of a, b, d are different
    C.
    Program 1 has syntax error, program 2 is not
    D.
    Program 2 has syntax error, program 1 is not

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this C code?

        int main()
        {
            int a = 1, b = 1, c;
            c = a++ + b;
            printf("%d, %d", a, b);
        }
  20. A.
    a = 1, b = 1
    B.
    a = 2, b = 1
    C.
    a = 1, b = 2
    D.
    a = 2, b = 2

    View Answer

    Workspace

    Discuss Discuss in Forum