If statement in c++
If statement The if section structure is used to select or determine a course of action that depends on the values of program variables. A very simple example of the need for such a structure would be a program to find the roots of quadratic equation based on the values of coefficients of the equation. Depending on the value of a, b, and c in the quadratic equation there are either 0, 1,0r 2 roots of the equation. The procedure followed is to evaluate the discriminate and based on its value we would assign 0, 1, or 2 to the variable indicating the number of roots of the equation. The simple if statement is used when a course of action consists of (a) executing a statement or block of statements, or (b) NOT executing the statement or block of statements. The syntax of If statement is: If (logical expression) statement 1; next_statement If the logical expression is TRUE, statement is executed and then next_statement is executed. If the logical expression is FALSE, ...