0
What will be output ? And what is that bracket operator?
12 Réponses
+ 4
I can give another example hope u will understood much better.
Everything in the parenthesis is operated first from left to right it is read like this
Int k=-5;
Int a=(k++,++k);
a= (-4,-3);
a=-3;
After reading everything inside parenthesis last value was -3 so its was assign to a and output is -3
+ 4
Actully u have not write code proper it giving errors
U wrote like this in line 8 which is completely wrong
d(a++ ,b ,a ); this means u calling function and u not defined function definition so how it will be call .here u should write like this
d=(a++ ,b ,a );
If u print value of d theñ Output will be 2 always last VALUE will be print it behave like Stack first u push value of a which is 1 after then u use post increment here value will increase so( a) will be 2 and after u pushing b then u write a so last value will be print and a was 2 becoz it was incresed a++ before insert of b
+ 3
Gaurav Kamble its working properly try in other ide or compiler its giving warnings only read what errors showing comman has no effect . Its just warning.
+ 3
+ 2
Aniket was right, variable <d> can be initialized by multiple values, each expression inside the parentheses () will be evaluated, but in the end, only the last expression in the parentheses will be used as the value to be assigned for <d>.
To understand this behaviour, have a look at this http://www.c4learn.com/c-programming/c-comma-operator/
+ 2
Gaurav Kamble 🤣😂😂😄😇 Thankyou
+ 1
The code has error.
What bracket operator? which line?
+ 1
But it runs in other compilers . Bracket operator on 8th line
I don't have any idea how it works. @Ipang
+ 1
Gaurav Kamble Did you mean something like this:
#include <stdio.h>
int main() {
int a=1 , b=3 , d;
d = (a++ ,b ,a );
printf ("%d",d);
return 0;
}
+ 1
Done Aniket Sandhilya
0
0
Still it's not running but the answer is 2 rkk