ProgrammingHardProduct-company MCQ pattern
Assume 32-bit int. What is printed?
Assume 32-bit int. What is printed?
int a = 4, b = 7;
int max = (a > b) ? a : b;
int min = (a < b) ? a : b;
printf("%d %d %d", max, min, max + min);- A. 7 4 11
- B. 4 7 11
- C. 7 7 14
- D. 4 4 8
Correct answer: A. 7 4 11
a > b (4>7) is false, so max takes the else-branch, b=7. a < b (4<7) is true, so min takes the true-branch, a=4. max+min = 7+4 = 11.
More C Programming questions
- What happens when this runs? c int p; if (p != NULL) { printf("%d", p); } else { printf("null"); }
- Assume a 64-bit LP64 ABI. What is printed? c struct Inventory { char name[16]; int quantity; double price; }; void restock(struct…
- Assume 32-bit int. What is printed? c #define SWAP(a, b, type) do { type t = a; a = b; b = t; } while (0) int main(void) { int x = 1, y =…
- Assume 32-bit int. What is printed? c int x = 5, y = 3; int result = x++ - ++y; printf("%d %d %d", x, y, result);
- What is printed? c int main(void) { int a = 1, b = 2, c = 3, d = 4; int result = (a < b) ? ((c < d) ? 1 : 2) : ((c < d) ? 3 : 4)…
- What is printed? c int main(void) { int scores[5] = {85, 92, 78, 95, 88}; int max = scores[0]; for (int i = 1; i < 5; i++) { if (scores[i]…