Home » C Programming » Operators » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int n1 = 15;
    int n2 = 16;
    n1 < n2 ? n1 = n1 + 1 : n2 = n2 + 1;
    printf("%d", n1);
    }
    1. 15
    2. 16
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: C

Compilation Error

main.c: In function ‘main’:
main.c:6:36: error: lvalue required as left operand of assignment
n1 < n2 ? n1 = n1 + 1 : n2 = n2 + 1;



Your comments will be displayed only after manual approval.