Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Switch Calculator | Conditional Control Flow Practice
C Conditional Statements

bookChallenge: Switch Calculator

Tarefa

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.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Switch Calculator

Deslize para mostrar o menu

Tarefa

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

some-alt