Discussion
What will be the value of d in the following program?
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = b + c == a;
printf("%d", d);
}
Answer: B
Correct answer: 1
== binds tighter than =, so the statement is d = ((b + c) == a). Since \(5 + 5 = 10\) equals a, the comparison is true and yields 1. Had = bound tighter the code would not even compile, since d = b + c is not something you can compare in that position.
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