"if"
tell the program execute the section of code when the condition evaluates to
true.
Syntax
if(condition){
//
Executes if the condition true
}
IfStmt.kt
fun main(args: Array<String>) { var marks: Int = 20 if (marks < 35) { println("You failed in the Exam. Better luck next time"); } marks = 55 if (marks < 35) { println("You failed in the Exam again. Better luck next time"); } }
Output
You failed in the Exam. Better luck next time
No comments:
Post a Comment