For every if statement must there be a corresponding else statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

For every if statement must there be a corresponding else statement

for example I am nesting three if statement together can I use only one else statement of I have to write three else statement also

6th Feb 2018, 12:56 PM
Fakorede Damilola
4 Answers
+ 14
You can have an if statement without a corresponding else statement.
6th Feb 2018, 1:16 PM
Hatsy Rei
Hatsy Rei - avatar
+ 14
not necessary
6th Feb 2018, 2:09 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
You can use unlimited number of if statement without else statement
6th Feb 2018, 1:31 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 9
if () {} if () {} else {} if () {} else if () {} else {} if () {} else if () {} if () {if () {} else {}} if () {if () {} else {}} else {} ........... Everything is accepted......
6th Feb 2018, 1:07 PM
Valen.H. ~
Valen.H. ~ - avatar