SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
Java program to accept two numbers and add
Java program to accept two numbers and add
Output:
Enter numbers to print its sum
5
6
The sum of 5 and 6 is 11
Implementation:
import java.util.*; import java.lang.*; import java.io.*; class CodeRegister { public static void main (String[] args) throws java.lang.Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s=br.readLine(); System.out.println("Enter numbers to print its sum"); int i=Integer.parseInt(s); s=br.readLine(); int j=Integer.parseInt(s); System.out.println("The sum of "+i+" and "+j+" is "+(i+j)); } }
PREVIOUS
NEXT
HOME