Are the following operators valid? If they are, what will be the values of the variables x and y?
int x = (1,024); // --1--
int y;
y = 1,024; // --2--
Explanation
The first statement consists of two expressions, separated by a comma operator. The value of the whole expression is the value of the right expression 024, 20 in the octal notation.
The second statement is also correct, but due to the priority of operations it will execute only assignment operation: (y = 1), 024; The last value is not used.

Follow CodeGalaxy

Mobile Beta

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