Java Program to add two number

0
Share

In this program, you’ll learn to store and add two integer numbers in Java. After addition, the final sum is displayed on the screen.

Example – Program to add two number

import java.util.*;
public class addition{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter two number : ");
        int no_1,no_2,addition_of_two_no;
        no_1=sc.nextInt();
        no_2=sc.nextInt();
        addition_of_two_no =no_1 + no_2;
        System.out.println("The addition of two number is : " +addition_of_two_no);
    }
}

Output

Enter two number : 5 9
The addition of two number is : 14

n this program, two integers 5 and 9 are stored in integer variables first and second respectively.

Then, first and second are added using the + operator, and its result is stored in another variable sum.

Finally, sum is printed on the screen using println() function.

Read more

  • What are the List of CSS3 New Features ?
    CSS3 is the latest version of the normal CSS . CSS3 adds several new styling features and improvements to enhance the web presentation capabilities. Text Effect in...
  • CSS Basic Property
    What is CSS ? CSS stands for Cascading Style Sheets. CSS basically used in designing the web tags & pages. CSS is the most popular used...
  • Java Program to swap two number use 3rd variable
    In this program, you’ll learn to Program to swap 2 number with 3rd variable in Java. After write the code, the final output is displayed on...
  • Java program to multiply two floating point number
    In this program, you’ll learn to Program to multiply two floating point number in Java. After write the code, the final output is displayed on the...
  • Java Program to find the ASCII value of a character
    In this program, you’ll learn to Program to find the ASCII value of a character in Java. After write the code, the final output is displayed...
  • Java Program to calculate quotient & reminder
    In this program, you’ll learn to Given Number is even or odd in Java. After write the code, the final output is displayed on the screen....
%d bloggers like this: