निम्नलिखित कोड का आउटपुट क्या होगा?
What will be the output of the following code ?
#include <stdio.h>
void solve() {
int b = 4;
int res = b++ + ++b + ++b;
printf("%d", res);
}
int main() {
solve();
return 0;
}
A)
B)
C)
D)
Explanation:
The code calculates the result of the expression b++ + ++b + ++b
, where b
starts at 4:
b++
uses the value 4, then incrementsb
to 5.++b
incrementsb
to 6 and uses that value.++b
incrementsb
to 7 and uses that value.
The sum is 4 + 6 + 7 = 17
.
Output: (C) 17.