Which of the following statement is correct about the code snippet given below?
#include <stdio.h>
int main()
{
float z = 12.35, c = 10;
if( ++z -z)
c += z;
else
c -= z;
printf( "%f %f", z, c);
return 0;
}
Answer: A
Correct answer: The program will result in compile time error
The statement is written c - = z; with a space between the two characters. C reads - and = as two separate tokens there, so the line parses as c - (= z), which is a syntax error. A compound assignment operator has to be written as one token: c -= z;.
Please log in or register to report this question.