Short Circuit Proof
C
Medium
9 views
Problem Description
Write the expression: (a > 0) && (++b > 5). If a = 0, will b be incremented or not? Verify by testing short-circuit evaluation.
Official Solution
#include <stdio.h>
int main() {
int a = 0;
int b = 5;
if ((a > 0) && (++b > 5)) {
printf("Condition truen");
} else {
printf("Condition falsen");
}
printf("Value of b after expression = %dn", b);
return 0;
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!