LearnFrenzy
Sign in Take a free test

Bitwise Operators · Predict the Output · Question 1

Output of 6 & 3, 6 | 3 and 6 ^ 3 in C Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    int a = 6, b = 3;
    printf("%d %d %d\n", a & b, a | b, a ^ b);
    return 0;
}
  • A 2 7 5 Correct
  • B 2 7 1
  • C 1 7 5
  • D 3 6 5
Correct Answer: Option A

110 & 011 = 010 (2); 110 | 011 = 111 (7); 110 ^ 011 = 101 (5).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links