The construction
if (expression)
statement
else if (expression)
statement
else if (expression)
statement
else
statement
This sequence of if statements is the most general way of writing a multi-way decision. The expressions are evaluated in order; if any expression is true, the statement associated with it is executed and this terminates the whole gain.
Mathematic expression 0<x<10 must write using AND operator: if( x>0 && x<10)
Mathematic expression x<0 or x>10 must write using OR operator: if( x<0 || x>10)
Example
if (n>0 && a<b) printf(…); else if (n>0 && a>b)
printf(…);
else if (n<0 && a<b)
printf(…);
else if (n<0 && a>b)
printf(…);
else
printf (“No solution! \n”);
NOTE! Exercises for that chapter can be found in quizzes Exercises 4 and P3-4 where these skills will also be tested. It is also important that the student does these examples above.