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

CSE MCQs :: C-MCQs

  1. What is the output of this C code?

        int main()
        {
            int a = 1, b = 1, d = 1;
            printf("%d, %d, %d", ++a + ++a+a++, a++ + ++b, ++d + d++ + a++);
        }
  2. A.
    15, 4, 5
    B.
    9, 6, 9
    C.
    9, 3, 5
    D.
    6, 4, 6

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. For which of the following, "PI++; code will fail?
  4. A.
    #define PI 3.14
    B.
    char *PI = A";
    C.
    float PI = 3.14;
    D.
    Both (A) and (B)

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is the output of this C code?

        int main()
        {
            int a = 10, b = 10;
            if (a = 5)
            b--;
            printf("%d, %d", a, b--);
        }

  6. A.
    a = 10, b = 9
    B.
    a = 10, b = 8
    C.
    a = 5, b = 9
    D.
    a = 5, b = 8

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the output of this C code?

        int main()
        {
            int i = 2;
            int j = ++i + i;
            printf("%d\n", j);
        }
  8. A.
    6
    B.
    5
    C.
    4
    D.
    Compile time error

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Comment on the output of this C code?

        int main()
        {
            int i = 2;
            int i = i++ + i;
            printf("%d\n", i);
        }
  10. A.
    = operator is not a sequence point
    B.
    ++ operator may return value with or without side effects
    C.
    it can be evaluated as (i++)+i or i+(++i)
    D.
    Both a and b

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the output of this C code?


        int main()
        {
            int i = 0;
            int x = i++, y = ++i;
            printf("%d % d\n", x, y);
            return 0;
        }

  12. A.
    0, 2
    B.
    0, 1
    C.
    1, 2
    D.
    Undefined

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of this C code?

        int main()
        {
            int i = 10;
            int *p = &i;
            printf("%d\n", *p++);
        }
  14. A.
    10
    B.
    11
    C.
    Garbage value
    D.
    Address of i

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What is the output of this C code?

        void main()
        {
            int x = 97;
            int y = sizeof(x++);
            printf("X is %d", x);
        }
  16. A.
    X is 97
    B.
    X is 98
    C.
    X is 99
    D.
    Run time error

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of this C code?

        void main()
        {
            int x = 4, y, z;
            y = --x;
            z = x--;
            printf("%d%d%d", x,  y, z);
        }
  18. A.
    3  2  3
    B.
    2  3  3
    C.
    3  2  2
    D.
    2  3  4

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. 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);
        }
  20. A.
    4
    B.
    8
    C.
    1
    D.
    Run time error

    View Answer

    Workspace

    Discuss Discuss in Forum