RApli AndrAs
0
Q:

addition of two numbers in java

import java.util.Scanner;
public class AddTwoNumbers
{
   public static void main(String[] args)
   {
      int a, b, c;
      System.out.println("Please enter two integers to add : ");
      Scanner sc = new Scanner(System.in);
      a = sc.nextInt();
      b = sc.nextInt();
      c = a + b;
      System.out.println("Sum of two numbers = " + c);
      sc.close();
   }
}
1
public class AddTwoNumbers {

   public static void main(String[] args) {
        
      int num1 = 5, num2 = 15, sum;
      sum = num1 + num2;

      System.out.println("Sum of these numbers: "+sum);
   }
}
1

New to Communities?

Join the community