Add Numbers

  1. Write a program in Java to Add two numbers

  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);

   }

}

Output

 

Leave Comment

Important Topics

Title
Run and Compile
Hello World Program
User Input
Add Numbers
Sum of Two Numbers
Even Numbers
Odd numbers from 1 to n or 1 to 100
Even or Odd number
Average of 3 numbers
Fibonacci Series using loops
Generate random number
Largest of three Numbers
Decimal to octal conversion
Quotient and Remainder
Simple Interest
Compound Interest