857 views
0 0 votes

Output is 7.

But can someone justify, how?

#include <stdio.h>
int f(int a, int b) {
        printf("%d", a + b);
        return 0;
}
int main() {
        f((2, 3), 4);
        return 0;
}

 

1 Answer

0 0 votes
When you do int a=(2,3) => a=(3) => a=3

 comma evaluated first as it is in bracket which is 3 and then it is assigned to variable a

So 3+4 = 7 will be output
• edited by
Position:
Show:

Related questions

7 7 votes
3 answers 3 answers
1.7k
1.7k views
Parshu gate asked Nov 20, 2017
1,708 views
What is the output of the following program?#include<stdio.h int main() { int array[]={10, 20, 30, 40}; printf(“%d”, -2[array]); return 0; }$-60$$-30$$60$Garbage value
0 0 votes
0 0 answers
902
902 views
iarnav asked Jul 30, 2018
902 views
for every j != i in {0,....,n-1} is it like for j=0 to n-1; j !=i ; ++j
4 4 votes
1 1 answer
2.8k
2.8k views
Parshu gate asked Nov 13, 2017
2,838 views
main( ){int n[3][3] = {2, 4, 3,6, 8, 5,3, 5, 1} ;printf ( "\n%d %d %d", *n, n[3][3], n ) ;}
1 1 vote
4 answers 4 answers
1.1k
1.1k views
Jonathan Decosta asked Jul 6, 2015
1,083 views
int main() { int i = 255; char *p; p = &i; printf("%d", *p); return 0; }