Comma Operator:: Int A 5, B 6 Void Fun (A, B)
Comma Operator:: Int A 5, B 6 Void Fun (A, B)
//
2, 3 will return 3
Therefore j = 3;
Note :
Assigning more than one value or initialization of multiple
variables at a time will results in compilation errors.
Example:
int a = b = c = 1; and
int a, b , c;
int j;
int j = 1, 2, 3;
results in errors.
a = b = c = 1;
j = 1 , 2 , 3;
int i;
i = 1, 2;
if (x == 1)
y = 2, z = 3, cout<<y<<z;
For practice :
1)
int x = 10;
int y = (x++, ++x);
printf("%d", y);
2)
int x = 10, y;
y = (x++, printf("x = %d\n", x), ++x, printf("x = %d\n", x), x++);
printf ("y = %d\n", y);
printf ("x = %d\n", x);
3)
a) return a=1, b=2, c=3;
b) return (1), 2, 3;
4)
int choice = 2 ;
switch(choice)
{
case 1,2,1:
printf("\ncase 1");
break;
For more details: http://comsciguide.blogspot.in/2015/06/comma-lowest-priority-operator.html
case 1,3,2:
printf("\ncase 2");
break;
case 4,5,3:
printf("\ncase 3");
break;
}
5)
int x =1 , y =2;
if ( y > x , y < x )
printf("\n y < x ");
else
printf("\n x < y ");