Challenge: Switch Calculator
Taak
Swipe to start coding
Write a function that takes two integers and a character representing an operator (+, -, *, or /). Use a switch statement to perform the corresponding arithmetic operation:
- If the operator is
+, print the sum of the two numbers; - If the operator is
-, print the difference of the two numbers; - If the operator is
*, print the product of the two numbers; - If the operator is
/, print the quotient of the two numbers; - If the operator is not one of the above, or if division by zero is attempted, return zero and print zero.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 2
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Suggested prompts:
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Geweldig!
Completion tarief verbeterd naar 9.09
Challenge: Switch Calculator
Veeg om het menu te tonen
Taak
Swipe to start coding
Write a function that takes two integers and a character representing an operator (+, -, *, or /). Use a switch statement to perform the corresponding arithmetic operation:
- If the operator is
+, print the sum of the two numbers; - If the operator is
-, print the difference of the two numbers; - If the operator is
*, print the product of the two numbers; - If the operator is
/, print the quotient of the two numbers; - If the operator is not one of the above, or if division by zero is attempted, return zero and print zero.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 2
single