Skip to content

Sum of Two Inputs

Read two numbers and print their sum.

package DSA.Basics;
import java.util.*;
public class sumof2input {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
System.out.println("Enter the numbers and press enter");
int a = sc.nextInt();
int b = sc.nextInt();
int sum = a + b;
System.out.println(sum);
}
}
}