Adding two Numbers in Java
Adding two numbers in java is a simple task. Adding two variables in java follows the fundamental addition rule of mathematics. First, you have to declare to Integer variables (Like n1 & n2). After declaring the variable then you have to assign a value.
Objective:
Add two numbers in Java.
Sample Input
Input Number 1: 4
Input Number 2: 5
Output = 9
Code
public static void main (String args[]){int n1 = 4;int n2 = 5;int n = n1+n2;System.out.println(n);}}
Output
9
0 Comments