Sunday 10 December 2017

Kotlin: if-else statement

If the condition true, then if block code will execute, otherwise else block code will execute.

Syntax:
if(condition){

}else{

}

IfElse.kt
fun main(args: Array<String>) {
 var marks: Int = 65

 if (marks < 35) {
  println("You failed in the Exam. Better luck next time");
 } else {
  println("You passed in the exam")
 }
}

Output

You passed in the exam



Previous                                                 Next                                                 Home

No comments:

Post a Comment