Thursday, September 19, 2013

Write A Java Program To Add Two Numbers

 

/******************************************************
Program       :  Write A Java Program To Add Two Numbers
*******************************************************/

/*-----------------<< Program  >>-------------------*/

import java.io.*;
import java.util.*;

class Add
{
public static void main(String args[])
{
int a,b,c;
Scanner in=new Scanner(System.in);
System.out.println("Enter 1st no : ");
a=in.nextInt();
System.out.println("Enter 2nd no : ");
b=in.nextInt();
c=a+b;
System.out.println("Addition : "+c);
}
}


/*-----------------<< Output  >>-------------------*/


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\JABIR>cd\

C:\>cd C:\Program Files\Java\jdk1.6.0_04\bin

C:\Program Files\Java\jdk1.6.0_04\bin>javac Add.java

C:\Program Files\Java\jdk1.6.0_04\bin>java Add
Enter 1st no : 5
Enter 2nd no : 7
Addition : 12

C:\Program Files\Java\jdk1.6.0_04\bin>
Best Regards,

No comments:

Post a Comment