Discussion
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;.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development