Challenge: Switch Calculator
Tarea
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 2
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 9.09
Challenge: Switch Calculator
Desliza para mostrar el menú
Tarea
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 2
single