Challenge: Switch Calculator
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 2
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 9.09
Challenge: Switch Calculator
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 2
single