0

When is else if used instead of if else ?

10th Jul 2016, 1:03 PM
Umed Jadhav
Umed Jadhav - avatar
2 Answers
0
if else is used when you want to check for 1 thing and everything else can fall under the else. else if is used if you are checking multiple things. Example, you have a program checking to see if user inputs yes or no. You'd do, if (blahblah == yes) do this, else if(blahblah == no) do this. Can even add an else at the end in case they put anything else that doesn't fit. Example of just an if else. Your program asks a question and you only want the correct answer. if(answer == correct) yay, else(doesn't matter what they put, if it's not correct it's wrong) you're answer isn't correct.
10th Jul 2016, 1:54 PM
James
James - avatar
0
when you have many conditions
8th Sep 2016, 3:57 AM
abd alkader alnazer
abd alkader alnazer - avatar