Create a flowchart that will input 3 numbers. the first two numbers will be the numbers that will be solved. the third number will be the operation.
1- Addition
2- subtraction
3- Multiplication
4- Division
with showing the answer.
Brainliest ko kapag picturr
Answers & Comments
Answer:
python:
def calculator():
try:
cal = int(input("enter your first number: "))
except ValueError:
print("please enter a number not a word")
calculator()
try:
cal2 = int(input("1: add, 2: subtract, 3: multiply, 4: divide: "))
except ValueError:
print("please enter a number not a word")
calculator()
try:
cal3 = int(input("enter your second number: "))
except ValueError:
print("please enter a number not a word")
calculator()
if cal2 == 1:
r = cal + cal3
elif cal2 == 2:
r = cal - cal3
elif cal2 == 3:
r = cal * cal3
elif cal2 == 4:
r = cal / cal3
else:
print("number not in list")
calculator()
print(r)
qus = input("do you want to repeat?(y/n): ")
if qus == 'y':
calculator()
else:
exit(0)
C++:
#include <iostream>
using namespace std;
int main() {
int a;
int b;
int c;
cout << "enter your first number ";
cin >> a;
cout << "enter your second number ";
cin >> b;
cout << "enter operator: 1: add, 2: subtract, 3: multiply, 4: divide ";
cin >> c;
if (c < 2) {
cout << "it is " << a + b;
} else if (c < 3) {
cout << "it is " << a - b;
} else if (c < 4) {
cout << "it is " << a * b;
} else if (c < 5) {
cout << "it is " << a / b;
} else {
cout << "it is not in the list.";
}
return 0;
}