निम्नलिखित कोड का आउटपुट क्या होगा?
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 expression b++ + ++b + ++b
evaluates as follows:
b++
uses the value ofb
(4) and increments it to 5.++b
incrementsb
to 6, then uses it.++b
incrementsb
to 7, then uses it.
So, the sum is 4 + 6 + 7 = 17
.
Correct Answer:
(C) 17.