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

Android App Version Update using the following cordova cli commands

75 inspirational quotes that will change your life

Retrieval Image From DataBase and Display on WebPage by Using Servlets.