Table of Contents
What is the difference between if and if-else statement ?
What is the difference between if and if-else statement ?
With the if statement, a program will execute the true code block or do nothing. It is little bit different from switch statement as it can decide between two in normal conditions.
With the if/else statement, the program will execute either the true code block or the false code block so something is always executed with an if/else statement.
Why do we use nested if -else structure ?
Ans: When a series of decision is required, nested if-else statement is used.
Nesting means using one if-else construct within other .
Write down a program for testing either a given number is +ve or –ve.
Create the equivalent of a four-function calculator. The program should request the user to enter a number, an operator, and another number. (Use floating point) It should then carry out the arithmetical operation: adding, subtracting, multiplying, or dividing the two numbers
For more read here: