Showing posts with label addition of two number. Show all posts
Showing posts with label addition of two number. Show all posts

Sunday, November 2, 2014

, , ,

Program to add two numbers using command line argument 2

add



Code Box 
---------------------------------

/*Program to add two numbers using command line argument 2 */

class add
{
public static void main(String x[])
{
int a,b,c;

System.out.print("\nzeroth argument :"+x[0]);
a=Integer.parseInt(x[0]);
//zeroth argument in a
System.out.print("\nvalue of a= "+x[0]);


System.out.print("\nfirst argument :"+x[1]);
b=Integer.parseInt(x[1]);
//first argument in b
System.out.print("\nvalue of b= "+x[1]);

c=a+b;

System.out.print("\nSum of a+b= "+c);

}
}

Publisher: Brijmohan Lal Sahu - 3:10 AM
, ,

Program to add two numbers using command line argument.



Code Box
-----------------------------

/*Program to add two numbers using command line argument */

class add
{
public static void main(String x[])
{
int a,b,c,d;

System.out.print("\nzeroth argument :"+x[0]);
a=Integer.parseInt(x[0]);
//zeroth argument in a
System.out.print("\nvalue of a= "+x[0]);


System.out.print("\nfirst argument :"+x[1]);
b=Integer.parseInt(x[1]);
//first argument in b
System.out.print("\nvalue of b= "+x[1]);

c=a+b;

System.out.print("\nSum of a+b= "+c);

d=Integer.parseInt(x[0])+Integer.parseInt(x[1]);
System.out.print("\nSum of arguments is ="+d);

}
}

Publisher: Brijmohan Lal Sahu - 3:05 AM