ProgrammingHardProduct company OA
What is printed?
What is printed?
printf("%#x %#o %x", 255, 8, -1 & 0xFF);- A. 0xff 0o10 ff
- B. ff 10 ff
- C. 0xff 010 ff
- D. 0xff 010 ffffffff
Correct answer: C. 0xff 010 ff
The # flag adds the base prefix: 0x for hex and a leading 0 for octal (8 is 10 in octal, shown as 010). -1 & 0xFF keeps the low 8 bits, 255, printed as ff. '0o' is Python's octal prefix, not C's.
More C Programming questions
- Assume 8-bit unsigned char. What is printed? c printf("%d %d %d", (int)-3.7, (unsigned char)-1, (int)(0.1 30));
- What is printed? c int ways(int amt, int k) { static const int c[] = {1, 2, 5}; if (amt == 0) return 1; if (amt < 0 || k == 0) return 0…
- On an LP64 system (8-byte pointers, 4-byte int), what is printed? c int a[10]; printf("%zu %zu %zu", sizeof(&a), sizeof(&a), sizeof(a + 0));
- What is printed? c int i = 0, j = 0; if (i++ & j++) ; if (i++ && j++) ; printf("%d %d", i, j);
- What is printed? c int a[6] = {4, 8, 15, 16, 23, 0}; int find(int x) { a[5] = x; int i = 0; while (a[i] != x) i++; return i < 5 ? i : -1…
- For ints a, b >= 0, which test correctly tells, before adding, whether a + b would overflow?