forked from vinay-kumar99/Hactoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.cpp
40 lines (30 loc) · 945 Bytes
/
calculator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
num_1 = int(input('Enter your first number: '))
num_2 = int(input('Enter your second number: '))
# Addition
print('{} + {} = '.format(num_1, num_2))
print(num_1 + num_2)
# Subtraction
print('{} - {} = '.format(num_1, num_2))
print(num_1 - num_2)
# Multiplication
print('{} * {} = '.format(num_1, num_2))
print(num_1 * num_2)
# Division
print('{} / {} = '.format(num_1, num_2))
print(num_1 / num_2)
num_1 = int(input('Enter your first number: '))
num_2 = int(input('Enter your second number: '))
if choice == '+':
print('{} + {} = '.format(num_1, num_2))
print(num_1 + num_2)
elif choice == '-':
print('{} - {} = '.format(num_1, num_2))
print(num_1 - num_2)
elif choice == '*':
print('{} * {} = '.format(num_1, num_2))
print(num_1 * num_2)
elif choice == '/':
print('{} / {} = '.format(num_1, num_2))
print(num_1 / num_2)
else:
print('Enter a valid operator, please run the program again.')