adplus-dvertising
frame-decoration

Question

What is the value of i and j in the below 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

Answer: (c).i value is 1 and j value is undefined

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the value of i and j in the below code? #include <stdio.h> int x = 0; int main() { int i = (f() + g()) | g(); //bitwise or int j =...

Similar Questions

Discover Related MCQs

Q. Which of the following operators has an associativity from Right to Left?

Q. Which operators of the following have same precedence?

P. "!=", Q. "+=", R. "&lt;&lt;="

Q. Comment on the following statement?

n = 1;
printf("%d, %dn", 3*n, n++);

Q. Which of the following option is the correct representation of the following code?

e = a * b + c / d * f;

Q. What care must be taken during swapping 2 numbers?

b = (b / a);
a = a * b;
b = a / b;

Q. Which of the following is the correct order of evaluation for the given expression?

a = w % x / y * z;

Q. Which function in the following expression will be called first?

a = func3(6) - func2(4, 5) / func1(1, 2, 3);

Q. Which of the following operator has the highest precedence in the following?

Q. Which of the following is a ternary operator?

Q. Which of the following are unary operators?

Q. Where in C the order of precedence of operators do not exist?

Q. Associativity of an operator are:

Q. Which of the following method are accepted for assignment?

Q. Which of the following is NOT possible with any 2 operators in C?

Q. Which of the following is possible with any 2 operators in C?

Q. Which of the following operators has the lowest precedence?

Q. Which of the following operator takes only integer operands?

Q. In an expression involving || operator, evaluation

I. Will be stopped if one of its components evaluates to false
II. Will be stopped if one of its components evaluates to true
III. Takes place from right to left
IV. Takes place from left to right

Q. In C programming language, which of the following type of operators have the highest precedence

Q. Which of the following comments about the ++ operator are correct?