java program to add two numbers

Java program to add two numbers

Code:

public class Add {
    public static void main(String args[])
    {
        int a=5, b=10;
        int c;
        c= a + b;
        System.out.printf("Sum of a:%d and b:%d is:%d%n", a, b, c);
        //we can also use this- System.out.println("Sum of a:" +a+ " and b:"+b+" is:"+c);
    }
}

Output:

Make toss

About the Author: Make toss

Leave a Reply

Your email address will not be published. Required fields are marked *

error: