Condition | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Condition

Does if and else condition stand together in code function?

30th Dec 2016, 9:58 AM
Rizwan Aslam
Rizwan Aslam - avatar
3 Respostas
+ 6
Like what Nahuel said, 'if' can stand alone while 'else' can only exist if 'if' exist. ... now that hurts my brain. E.g. if (x == 1) { //codes } is valid, if (x == 1) { //codes } else if (x == 2) { //codes } is valid, else { //codes } is not valid.
30th Dec 2016, 10:48 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
not sure what is "stand together" but there can not be an else without if.
30th Dec 2016, 10:12 AM
Nahuel
Nahuel - avatar
+ 1
All else are if but not all if are else. lol
30th Dec 2016, 1:58 PM
Vincent Kordiak
Vincent Kordiak - avatar