Operators


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int p = 5, q = 4;
    p *= p + q;
    printf("%d\n", p);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    45


  1. What will be the output of the following C code snippet?
    #include <stdio.h>
    void main()
    {
    unsigned int m = -10;
    printf("%d", m);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    -10



  1. What will be the output of the following C code snippet?
     #include <stdio.h>
    void main()
    {
    2 < 3 ? return 2: return 3;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:4:17: error: expected expression before ‘return’
    2 < 3 ? return 2: return 3;


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    char p = 'p';
    int q = (p % 10)++;
    printf("%d\n", q);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Compilation Error

    main.c: In function ‘main’:
    main.c:5:25: error: lvalue required as increment operand
    int q = (p % 10)++;



  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int n = 12;
    int num = 2 == 3 && n++;
    printf("%d %d", num, n);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    0 12