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

void func(int a, int b, int c, int d)
{
   std::cout << a << b << c << d;
}

int main()
{
   int a = 0;
   func(++a, a++, ++a, a++);
   return 0;
}
Explanation
The order of calculating the arguments passed into the function is not defined. That's why the result of this code execution is undefined behavior. You may read the details here: Sequence point.

Follow CodeGalaxy

Mobile Beta

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