Home » C Programming » Operators » Question
  1. What will be the final values of p and q in the following C code?
     #include <stdio.h>
    int n = 0;
    int main()
    {
    int p = (funA() + funB()) | funB(); //bitwise or
    int q = funB() | (funA() + funB()); //bitwise or
    }
    int funA()
    {
    if (n == 0)
    return n + 1;
    else
    return n - 1;
    }
    int funB()
    {
    return n++;
    }
    1. k value is 0 and L value is 0
    2. k and L value are undefined
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: C

Compilation Error

main.c: In function ‘main’:
main.c:5:18: warning: implicit declaration of function ‘funA’ [-Wimplicit-function-declaration]
int p = (funA() + funB()) | funB(); //bitwise or
^~~~
main.c:5:27: warning: implicit declaration of function ‘funB’ [-Wimplicit-function-declaration]
int p = (funA() + funB()) | funB(); //bitwise or



Your comments will be displayed only after manual approval.