Add Two Numbers In Java - Math Traders

Latest

Add Two Numbers In Java

To add two numbers in Java we make a very simple program and under this program we do following things.
  1. we have to declare to three variables in the program.
  2. we initiate the values of any two variable.
  3. now store the sum of these two variables in into the third variable.
the example of this program in Java can be seen as:



public class addtwonumbers{

    public static void main(string[] args){

int a=5,b=6,sum;
sum=a+b;
System.out.println("sum of two numbers is \t" +sum);

    }
}

output of this c program will be : sum of two numbers is  11

No comments:

Post a Comment