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;
}
Discussion:
58 comments Page 4 of 6.
Atul jain said:
1 decade ago
Thanks Vedhashree.
Ani said:
2 decades ago
Can anyone explain this in a detailed way?
Vijay said:
2 decades ago
Here &, | and ^ are bitwise operators,then operations will be performed on operands at bit level.
& - AND , | - OR , ^ - XOR operators
(4)d = (0000100)b, (8)d = (0001000)b
& has higher precedence over |
By considering all these, you will get the answer as expected.
& - AND , | - OR , ^ - XOR operators
(4)d = (0000100)b, (8)d = (0001000)b
& has higher precedence over |
By considering all these, you will get the answer as expected.
Jalandhar said:
1 decade ago
Thans a lot @vijay
Javed said:
1 decade ago
Can anyone elaborate giving small example?
Sibaram said:
1 decade ago
Can't under stand please explain detail.
Koushik said:
1 decade ago
Thanx vedhasree...!!!
Mani said:
1 decade ago
i=4,j=8
|,&,^-these r bitwise operators so first we convert the iand j value to binary.
i=0100 j=1000
step1:
qus=i|j@j|i?
i|j=0100|1000=1100
j|i=1000|0100=1100
finally
i|j@j|i=1100&1100=1100=12
so the ans is 12 12 12
|,&,^-these r bitwise operators so first we convert the iand j value to binary.
i=0100 j=1000
step1:
qus=i|j@j|i?
i|j=0100|1000=1100
j|i=1000|0100=1100
finally
i|j@j|i=1100&1100=1100=12
so the ans is 12 12 12
Syed said:
1 decade ago
Thanks vedashree
Vikas said:
1 decade ago
Thanks vedhashree.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers