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 add two numbers
Java program to add two numbers
Output:
Enter two numbers to add them:
4
6
The Sum of 4 and 6 is 10
Implementation:
import java.util.*; import java.lang.*; import java.io.*; class CodeRegister { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); System.out.println("Enter two numbers to add them:\n"); int a=sc.nextInt(); int b=sc.nextInt(); System.out.println("The Sum of "+a+" and "+b+" is "+(a+b)); } }
PREVIOUS
NEXT
HOME