Comma Operator Trap
C
Hard
6 views
Problem Description
Write the expression: q = (a = 5, b = 10, a + b);. What is the value of q? Explain the evaluation sequence of the comma operator.
Official Solution
#include <stdio.h>
int main() {
int a, b, q;
q = (a = 5, b = 10, a + b);
printf("a = %dn", a);
printf("b = %dn", b);
printf("q = %dn", q);
return 0;
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!