【正文】
in ? Nested if statement: if (expression1) statement1。 else if (expression2) statement2。 else statement3。 ? Whether the indentation exists or not, the piler will, by default, associate an else with the closest previous unpaired if, unless braces are used to alter this default pairing A First Book of ANSI C, Fourth Edition 27 The ifelse Chain (continued) ? ifelse chain: if (expression1) statement1。 else if (expression2) statement2。 else statement3。 A First Book of ANSI C, Fourth Edition 28 The ifelse Chain (continued) A First Book of ANSI C, Fourth Edition 29 The ifelse Chain (continued) A First Book of ANSI C, Fourth Edition 30 The ifelse Chain (continued) A First Book of ANSI C, Fourth Edition 31 The ifelse Chain (continued) A First Book of ANSI C, Fourth Edition 32 The switch Statement Terminated with a colon default is optional If the break statement was omitted, the following case would be executed A First Book of ANSI C, Fourth Edition 33 The switch Statement (continued) A First Book of ANSI C, Fourth Edition 34 The switch Statement (continued) A First Book of ANSI C, Fourth Edition 35 Case Study: Data Validation ? Defensive programming is a technique where the program includes code to check for improper data before an attempt is made to process it further – Checking user input data for erroneous or unreasonable data is called input data validation ? Requirements: – Write a program to calculate the square root and the reciprocal of a userentered number. Validate that the number is not negative before attempting to take