JAVA Basic Programs -- Sum Of Two Numbers








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.





Comments

Popular posts from this blog

Why Mark Zuckerberg’s Choose 4

Error message when I run sudo: unable to resolve host (none)

Convert MBR to GPT