Operators


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    Ascii value of character getchar function returns


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int p = 2;
    short int k = 3;
    float var = 4;
    if (sizeof((p == 3) ? var : k) == sizeof(float))
    {
    printf("Float\n");
    }
    else if (sizeof((p == 3) ? var : k) == sizeof(short int))
    {
    printf("Short int\n");
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Float



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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    1


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int num1 = 12;
    int num2 = 10;
    int num3 = num1 < num2 ? num1 = num2 : num2++;
    printf("%d", num3);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    10



  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int num1 = 10;
    int num2 = 11;
    num1 < num2 ? num1++ : num2 = num1;
    printf("%d", num1);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:6:37: error: lvalue required as left operand of assignment
    num1 < num2 ? num1++ : num2 = num1;