What will be printed out as a result of the following code execution?
#include <iostream>

int foo()
{
    return 1, 2, 3, 4, 5;
}

int main()
{
    std::cout << foo() << std::endl;

    return 0;
}
Explanation
«5» will be printed out. The comma operator «,» works from left to right. It returns its second parameter by default. In the given example the execution will go as follows: ((((1, 2), 3), 4), 5)

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes