ProgrammingVery hardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
unsigned k = 0;
int len = -1;
printf("%d", k > len);
}- A. 1
- B. 0
- C. 3
- D. 2
Correct answer: B. 0
len is converted to unsigned, so it becomes 4294967295 and 0 > 4294967295 is false. A signed comparison would say 0 > -1 is true.
More C Programming questions
- How many integers in 0..15 are a power of two? Compute with this program. c #include <stdio.h> int main(void) { int c = 0; for (unsigned x…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {3, 1, 2}, swaps = 0; for (int i = 0; i < 3; i++) for (int j = 0; j < 2…
- What is printed? Assume uint32t is 32 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint32t h = 5381; const char s =…
- What is printed? c #include <stdio.h> #include <stdlib.h> struct R { int a, b; }; int cmp(const void p, const void q) { const struct R x =…
- How many values of n in 1..50 have bit 2 set (the value 4)? Compute with this program. c #include <stdio.h> int main(void) { int c = 0…
- What is printed? Assume int is 4 bytes. c #include <stdio.h> int main(void) { int m[4][5]; printf("%zu %zu", sizeof m / sizeof m[0]…