Kotlin Program:

- To print the sum of 2 numbers

Example:

User Input: 2,3

Output: 5

import java.util.Scanner
fun main(args: Array<String>) {
  
  print("Enter two numbers : ");
  val userInput = Scanner(System.`in`)
  var n1:Int = userInput.nextInt()
  var n2:Int = userInput.nextInt()
  
  print("Sum :"+ (n1+n2))
}

Output:

  Enter two numbers : 7
  9
  Sum : 16
Program
basic

Here, we use 2 variables (above code n1 & n2) to take numbers from the user

Now, Just use the add(+) operator to print the sum of the numbers

//use add(+) operator, must use inside curly-brackets [only for this operator]
println("Sum :"+ (n1+n2))

OR

//use add(+) operator,
println("Sum : ${n1+n2}")

For devision (/), subtraction (-), multiplication (*), you can use their respective operators

Concept

Coming Soon !

Quick
Tutorial

Quote

Make bold choices and make mistakes. It’s all those things that add up to the person you become.