Q. What will be the final values of i and j in the following C code?

Code:
#include <stdio.h>
    int x = 0;
    int main()
    {
        int i = (f() + g()) | g(); //bitwise or
        int j = g() | (f() + g()); //bitwise or
    }
    int f()
    {
        if (x == 0)
            return x + 1;
        else
            return x - 1;
    }
    int g()
    {
        return x++;
    }
  • (A) i value is 1 and j value is 1
  • (B) i value is 0 and j value is 0
  • (C) i value is 1 and j value is undefined
  • (D) i and j value are undefined
πŸ’¬ Discuss
βœ… Correct Answer: (C) i value is 1 and j value is undefined

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
236
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Monu Rathod
Publisher
πŸ“ˆ
86%
Success Rate