Question discussion

What is the output of the following C program?#include int main() { printf("%d %d %d", 5 & 3 | 4, 5 ^ 3

1557Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
int main() {
    printf("%d %d %d", 5 & 3 | 4, 5 ^ 3 << 1, ~5 + 1);
    return 0;
}
  • A5 3 -5
  • B5 6 -5
  • C1 3 -6
  • D7 3 -6
Correct answer: A

Explanation

By precedence, 5 & 3 | 4 = (5 & 3) | 4 = 1 | 4 = 5; 5 ^ 3 << 1 = 5 ^ 6 = 3; and ~5 + 1 = −6 + 1 = −5.

Discussion 0

Nobody has replied yet. Start the discussion!