Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what is the logic of this program

0 votes
asked Jun 18, 2019 by anonymous 1 flag
#include <stdio.h>
    void main()
    {
        int x = 0, y = 2, z = 3;
        int a = x & y |z;
        printf("%d", a);
    }

5 Answers

0 votes
answered Jun 19, 2019 by anonymous 1 flag

& and | are bit wise operators then operation will be performed as bit by bit
        given  x = 0, y = 2, z = 3;
          x & y |z means 000 & 010 | 011 
       

+1 vote
answered Jun 19, 2019 by shanmukha sai teja (160 points)
There is nothing in the logic You are getting values by operating of some bitwise operators. your initializing the integer values in the declaration part itself. So You are getting Direct Answer
0 votes
answered Jun 19, 2019 by anonymous
Answer is 3.that a will perform that condition.so,answer is 3
0 votes
answered Jun 20, 2019 by avi
0 votes
answered Jun 20, 2019 by saivikas
first bitwise and will operate so for x & y as x=0 it is "false". so answer for x & y is false .now for "or" operator first one is false it will check for next,that is z=3 which is true.3 is assigned to a Now a=3 so output is 3.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...