Sum of two number in java
Example
Input
5 6
Output
11
Steps
- Take two numbers as input from the user.
- Use the arithmetic operator addition'(+)' to perform the sum of two numbers.
- Print the result.
Programs
import java.util.Scanner;
class Main {
public static void main(String[] args) {
//Scanner
Scanner sc = new Scanner(System.in);
//take input
int a,b,c;
//take two input
a = sc.nextInt();
b = sc.nextInt();
c = a + b;
System.out.println(+c);
}
}
Comments
Post a Comment