what are the situation that if else ladder cannot be rewritten by switch statement?
Answers
Answered by
0
How can we eliminate the problems of the "switch" statement using "else if ladder"?
There are two problems with switch statements:
1 . if (record->student_id == search_id)
2. index = record->index;
3 . record_found = TRUE;
Second, related to the first is that an else can be associated with a different if than it looks like:
1.if (record->category == STUDENT)
2.if (record->student_id == search_id) {
3.index = record->index;
4.record_found = TRUE;
5.// Yes, we fixed the first bug.
6. }
7. else
8.process_staff_record(record);
Similar questions