What is the importance of the else if statement?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the importance of the else if statement??

4th Jul 2018, 7:10 PM
Nii
2 Answers
0
int age = 17; if(age >= 18) { // age is greater than or equal to 18 }else if(age >= 15) { // age is greater than or equal to 15 }else { // runs if age is less than 18 and less then 15 this will run } "else if" can check for different conditions in the same if "block"
4th Jul 2018, 7:25 PM
John
John - avatar
0
If : runs given a specific condition. Else if: runs if a prior if statement's conditions was false and a specific condition is true. If statements/else if statements have already been covered. Please usr the Q&A search before posting a question as to avoid creating a duplicate.
4th Jul 2018, 8:29 PM
josh mizzi
josh mizzi - avatar