Add Two Numbers in Scala

In this example, we will show you how to add two numbers in scala program language. The sample program and output has been attached in the same post.

Example Code

import java.util.Scanner;
object Addition {
def main(args: Array[String]) {
// defining the scanner object
var scanner = new Scanner(;
println("Enter the first number : ");
// reading input from user
var a = scanner.nextInt();
println("Enter the second number : ");
// reading input from user
var b = scanner.nextInt();
println("The Result is : "+(a+b));


Enter the first number :
Enter the second number :
The Result is : 50


No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *