Question
Write a program to add two numbers.
Enter the value of 1st number
10
Enter the value of 2nd number
30
40
Example 2:
Enter the value of 1st number
30
Enter the value of 2nd number
-10
20
Share code with your friends
Share on whatsapp
Share on facebook
Share on twitter
Share on telegram
Codes
Java
Python
Java
import java.util.Scanner;
public class AddTwoNumbers
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int a =0,b=0;
System.out.println("Enter the value of 1st number");
a=sc.nextInt();
System.out.println("Enter the value of 2nd number");
b=sc.nextInt();
// Adding A and B
int sum = a+b;
// Print the sum of a +b
System.out.println(sum);
}
}
Python
firstNumber=int(input("Enter your first number: "))
secondNumber=int(input("Enter your second number: "))
Sum=firstNumber+secondNumber
print("Sum of First and Second Number:", Sum)
Coding Store
Sale
ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale