C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - Find Output of Program (Q.No. 7)
7.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int i=4, j=8;
    printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j);
    return 0;
}
12, 12, 12
112, 1, 12
32, 1, 12
-64, 1, 12
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
58 comments Page 2 of 6.

Nilesh said:   8 years ago
@Sujithra.

The ans will be 1000.

In &(AND) operation,
1 & 1=1.
1 & 0=0.
0 & 1=0.
0 & 0=0.

Raghavi said:   8 years ago
Thanks for the explanation friends. It helps me to understand easily.

Raji said:   8 years ago
Thank you to all your answers and explanation.

Earl said:   8 years ago
Thanks to all your explanations.

Sujithra said:   9 years ago
What will be the answer when 1100&1000 occur in a program? please explain in detail.

Sonali said:   9 years ago
Good explanation @Abinandank.

Umesh Pandey said:   9 years ago
Tricky method.

i|j&j|i, i|j&j|i gives same value.

The option is only 12,12 ie A.
(1)

Mindmaster said:   9 years ago
Operators of same precedence are executed from left to right.

Shakshi said:   9 years ago
Thanks, @Vadhashree. it's a clear explanation.

Sushant said:   9 years ago
@Kavi.

& is a bitwise operator.

Whereas;

&& is a logical operator.


Post your comments here:

Your comments will be displayed after verification.