2

I am a beginner in coding C++.
I came across this piece of code.
I couldn't understand why the variable 'a' gets assigned value 5 and variable 'b' gets assigned the value 1.

#include <iostream>
using namespace std;

int main ()
{
    int a, b;
    a = 5, 2, 3;
    b = (5, 2, 1);

    cout << a<<endl;
    cout << b <<endl;
    cout << a + b;
    return 0;
}

The value of
'a' is 5,
'b' is 1.
But how?

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Mihir Mehta
  • 89
  • 1
  • 9

0 Answers0