#include <stdio.h> int main() { int i = 5, j = 10, k = 15; printf("%d ",…
2024
#include <stdio.h> int main() { int i = 5, j = 10, k = 15; printf("%d ", sizeof(k = i + j)); printf("%d", k); return 0; } Assume size of an integer as 4 bytes. What is the output of above program?
- A.
2 1
- B.
4 1
- C.
4 15
- D.
More than one of the above
- E.
None of the above
Attempted by 995 students.
Show answer & explanation
Correct answer: C
Step 1: The expression sizeof(k = i + j) is evaluated. The assignment k = i + j is performed, so k becomes 15. The result of the assignment is the value assigned, which is 15, and its type is int. Step 2: The sizeof operator returns the size of the type of the result, which is int. Given that the size of an integer is 4 bytes, the first printf prints 4. Step 3: The second printf prints the value of k, which is now 15. Thus, the output is 4 15.