912 views

1 Answer

Best answer
4 4 votes

Comma operator returns the value of the rightmost operand when multiple comma operators are used inside an expression.

 i = (1,2,3);

will return 3 to i.

Now consider the program

if(a++, b--, --b)

Here final value returned will value of b which will be zero condition become false so else part will executed .

Output:0,1

• selected by
Position:
Show:

Related questions

9 9 votes
3 3 answers
429
429 views
GO Classes asked Jun 17
429 views
What is the output of the following code?#include <stdio.h void update(int n, int *p) { if (n <= 0) return; *p = *p + n; update(n - 2, p); *p = *p + n; } int main() { int...
6 6 votes
2 2 answers
363
363 views
GO Classes asked Jun 17
363 views
What is the output of the following code?#include <stdio.h int fun(int n) { int x = n; if (n <= 0) return 0; x = x + 2; return x + fun(n - 2); } int main() { printf("%d",...
6 6 votes
2 2 answers
403
403 views
GO Classes asked Jun 17
403 views
How many times is $\texttt{fun()}$ called when the following code is executed? (Count the first call also).#include <stdio.h int fun(int n) { if (n <= 1) return 1; return...
6 6 votes
3 3 answers
370
370 views
GO Classes asked Jun 17
370 views
What is the output of the following code?#include <stdio.h int fun(int n) { if (n <= 1) return n + 1; if (n % 2 == 0) return fun(n - 1) + fun(n - 2); return fun(n - 2) + ...