In this program, the value of both numbers to be added are specified in the program itself. Once running this program you will get the sum of the predefined values.

```
public class AddingTwoNumbers {
public static void main(String[] args) {
int n1 = 4, n2 = 11, sum;
sum = n1 + n2;
System.out.println("Sum = "+sum);
}
}
```

`Sum = 15`

The scanner is a class in java that provides a way to take input fro the keyboard. Here the users can give value through their keyboard. The program takes value from the user and performs the calculations and prints the sum.

```
import java.util.Scanner;
public class AddingTwoNumbers {
public static void main(String[] args) {
int n1, n2, sum;
Scanner sc = new Scanner(System.in);
System.out.println("Enter First Number: ");
n1 = sc.nextInt();
System.out.println("Enter Second Number: ");
n2 = sc.nextInt();
sc.close();
sum = n1 + n2;
System.out.println("Sum of the given numbers are: "+sum);
}
}
```

```
Enter First Number:
10
Enter Second Number:
5
Sum of the given numbers are: 15
```

]]>```
#include <stdio.h>
int main() {
int n1, n2, sum;
printf("Enter the two numbers to add\n ");
scanf("%d %d", &n1, &n2);
//addition of two numbers
sum = n1 + n2;
printf("The sum of %d & %d = %d", n1, n2, sum);
return 0;
}
```

```
Enter the two numbers to add
7
5
The sum of 7 & 5 = 12
```

]]>```
#user defined addition of two numbers
x = int(input("Enter the value for number1\n"))
y = int(input("Enter the value for number2\n"))
#adding two numbers
sum = x + y
#Printing the sum
print('The sum of {0} and {1} is {2}'.format(x, y, sum))
```

```
Enter the value for number1
5
Enter the value for number1
6
The sum of 5 and 6 is 11
```

]]>