Java Program:

- To print the sum of 2 numbers

Example:

User Input: 2,3

Output: 5

import java.util.Scanner;
public class SumTwoNumber {
  public static void main(String []args) {
    int n1,n2;
    Scanner userInput = new Scanner(System.in);
    System.out.print("Enter two numbers : ");
    n1 = userInput.nextInt();
    n2 = userInput.nextInt();

    System.out.println("Sum :"+ (n1+n2));
  }
}

Output:

  Enter two numbers : 7
  5
  Sum : 12
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]
System.out.println("Sum :"+ (n1+n2));

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

Concept

Coming Soon !

Quick
Tutorial

Quote

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.