+ 1
Conditional Statement
Can a “if” statement be use without an “else” statement?
5 Antworten
+ 7
Yes in any language it is possible.
+ 3
It depends on the language. For whichever language you are interested in, the easiest way to get an answer is to just try it. If the compiler or interpreter doesn't complain, it works.
+ 2
Yes, if block statement use without else statement, and why use if-block statement mostly? because if the if-block condition false then it goes to else block statement, otherwise no problem if we use if-block statement without the else statement.
+ 1
Yes, the if statement can be used without “else” because if only executes the indented block of code as long as the condition evaluates fo True, while else only execute if the “if” statement does not evaluate to “True”.
- 1
Yes, if only the condition is “True”.