Introducing multiple if()… statements
The switch
statement tests a single value. Could we have done this another way? Yes – with the if()… else if()… else if()… else…
construct. We could have written the calc()
function using multiple if()… else…
statements, in this way:
double calc( double operand1 , double operand2 , char operator ) {
double result = 0.0;
printf( "%g %c %g = " , operand1 , operator , operand2 );
if( operator == '+' )
result = operand1 + operand2;
else if( operator == '-' )
result = operand1 - operand2;
else if( operator == '*' )
result = operand1 * operand2;
else if( operator == '/'
if( operand2...