In this program, we use two variables which have already contain values and sum of these numbers are stored in the third variable.
Xample:
File_name: Addition.java
For Compiling: javac Addition.java
For Execution: java Addition
Remember filename and class name must be the same
class Addition
{
public static void main(String[] args)
{
int a=10, b=20, c=0;
c=a+b;
System.out.println("Sum: "+c);
}
}
OutPut:
Sum: 30
That's it, I hope it is useful.
Thanks For reading.
No comments:
Post a Comment