Go to Top

Wednesday, 6 April 2011

To print the sum of two numbers

Question 7 : Write a program in Java to print the sum of two numbers given by the user.


Java Program :


public class sum
{
    public static void main(int a,int b)
    {
        int s;
        s=a+b;
        System.out.print("Sum = "+s);
    }
}

Input : 


a=10
b=20

Output : 


Sum = 30

2 comments:

ShareThis