What happens if you try to compile and run this program?
What happens if you try to compile and run this program?
#include <stdio.h>
int main (int argc, char *argv[]) {
int i =2, j = 1;
if(i / j)
j += j;
else
i += i;
printf("%d",i + j);
return 0;
}
Choose the right answer:
A . The program outputs 1
B . The program outputs 5
C . The program outputs 3
D . Compilation fails
E . The program outputs 4
Answer: E
Explanation:
In the if statement, i / j is 2 / 1, which is true. Therefore, the if block is executed, and j += j; doubles the value of j (j becomes 2).
After the if-else statement, printf("%d", i + j); prints the sum of i and the updated val-ue of j (2 + 2), which is 4.
Latest CLA-11-03 Dumps Valid Version with 40 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund
Subscribe
Login
0 Comments
Inline Feedbacks
View all comments