In this
program, we see how to add two numbers in java. To add two numbers in java,
first user enter two numbers using keyboard, then add both numbers using
(+) operator and display the result.
Java Program to Add Two Numbers
import java.util.Scanner;
public class Addition
{
public static void main(String args[])
{
int a, b;
Scanner c = new Scanner(System.in);
System.out.print("Enter First
Number : ");
a = c.nextInt();
System.out.print("Enter Second Number : ");
b = c.nextInt();
System.out.print("Sum of
"+a+" and "+b+" is " +(a+b));
}
}
OUTPUT:
Enter First Number : 5
Enter Second Number : 6
Sum of 5 and 6 is 11
0 comments:
Post a Comment