0

In this comma-separated expression. Why doesn't the x gets value an instead of b?

int main() {

int a=20;
int b=100;
int x;
x=(a,b);

cout<<x;
}

Gives output: 100

Yakk - Adam Nevraumont
  • 250,370
  • 26
  • 305
  • 497

1 Answers1

1

The comma operator evaluates the left hand side, discards it, evaluates the right hand side, returns it.

Yakk - Adam Nevraumont
  • 250,370
  • 26
  • 305
  • 497