Java program to find sum of two numbers

Hi friends, today I will show you how to write a java program to find sum of two numbers.





Here in the program we will ask two numbers from the user and we will display its result.




    
     import java.util.*;
class SumNo
{
    public static void main(String args[])
    {
       Scanner in = new Scanner(System.in);
       int a, b;
       System.out.println("Enter a number");
       a=in.nextInt();
       System.out.println("Enter a number");
       b=in.nextInt();
       System.out.println("Sum of the two numbers is: " +(a+b));
    }
    
}
    
  
Output: 
Enter a number 
Enter a number 
Sum of the two numbers is: 11

Hope you enjoyed reading our posts. You may also see other posts related to programming on our website.

Comments

Popular Posts