Basic Program Tasks Session 4





Bonjour, I come back to post c ++ language used else if.
So, Check it out !!! 

 

Else If

when there are multiple conditional statements that may all  
evaluate to true, yet you want only one if statement's body to 
execute. You can use an "else if" statement following an if 
statement and its body; that way, if the first statement is true, 
the "else if" will be ignored, but if the if statement is false, 
it will then check the condition for the else if statement. 
If the if statement was true the else statement will not be 
checked. It is possible to use numerous else if statements 
to ensure that only one block of code is executed. 

 
if ( <condition> ) {
  // Execute these statements if <condition> is TRUE
}
else if ( <another condition> ) {
  // Execute these statements if 
    <another condition> is TRUE and
  // <condition> is FALSE
}

 
 
 

Example :




1. Absolute Algorithm












this algorithm to determine the original number


2. Discount Algorithm













this algorithm is used to create a discount that if the buyer buys the item for $ 100000


3. Conversion Algorithms Day, Month and Year


 








this algorithm to change the day to year, month and day

 

4. Employee Salary Algorithm













This algorithm is used to provide a net salary to employees




Thanks, 
See You Next Time.

Comments