out put : 40 50 50Code:int main() { int a=10,b=20,c=30; c=(a=40,b=50); printf("%d %d %d \n",a,b,c); return 0; }
can any one explain me how this out came , how c assign to 50
i appreciate any replys
out put : 40 50 50Code:int main() { int a=10,b=20,c=30; c=(a=40,b=50); printf("%d %d %d \n",a,b,c); return 0; }
can any one explain me how this out came , how c assign to 50
i appreciate any replys
The result of the comma operator is the right subexpression. Where did you find this program, anyway?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Hi laserlight ,
"The result of the comma operator is the right subexpression" , i didt get this . if u dont mine can u explain me clearlly . can u give any example for this right subexpression
i facedout this in oneof my c interview .
Here is a simple example that demonstrates what I mean:
Code:#include <stdio.h> int main(void) { int x = (10, 20); printf("%d\n", x); return 0; }
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
A takes on the value 40 in line 4.
B takes on the value 50 in line 4.
The value of variable B is stored in C at line 4.
Read this Comma operator - Wikipedia, the free encyclopedia
If you would like the value of A stored in C you would edit it to.Code:i = (a, b, c); // stores c into i
Code:c = a=40, b=30
Last edited by JOZZY& Wakko; 12-17-2009 at 06:42 AM.
Wow, I feel like a total chode. I could've sworn that the result of an assignment operation was either a 1 or a 0.