Write a javascript code to accept 2 numbers from user to display addition, subtraction, multiplication and division of two numbers.
Answers
Answer:
Here the answer
Explanation:
1st Number : <input type="text" id="firstNumber" /><br>
2nd Number: <input type="text" id="secondNumber" /><br>
<input type="button" onClick="multiplyBy()" Value="Multiply" />
<input type="button" onClick="divideBy()" Value. ="Divide" />
Javascript code to accept 2 numbers from user to display addition, subtraction, multiplication and division of two numbers is,
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("1. Addition 2.Subtract 3.Multiplication 4.Division")
choice = int(input("Enter your choice: "))
if(choice == 1):
print("Addition of {} and {} = {}".format(a, b, a+b))
elif(choice == 2):
print("Subtraction of {} and {} = {}".format(a, b, a-b))
elif(choice == 3):
print("Multiplication of {} and {} = {}".format(a, b, a*b))
elif(choice == 4):
print("Division of {} and {} = {}".format(a, b, a/b))
else:
print("Wrong Choice")