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

bookChallenge: Math Operation Handler

Tarefa

Swipe to start coding

You're building a simple math operation processor that performs different calculations based on the selected operation type.

Use a switch statement to handle each operation type.

  1. Addition (case 1)
    • Add a and b.
    • Print "Adding numbers...".
  2. Subtraction (case 2)
    • Subtract b from a.
    • Print "Subtracting numbers...".
  3. Multiplication (case 3)
    • Multiply a by b.
    • Print "Multiplying numbers...".
  4. Division (case 4)
    • Check if b is not equal to zero.
    • If true, divide a by b and print "Dividing numbers...".
    • Otherwise, print "Error: Division by zero not allowed.".
  5. Default Case
    • Print "Invalid operation type." if the number doesn't match any valid case.
  6. Return the result of the performed operation.

Example

operationType = 3, a = 12.0, b = 4.0 => "Multiplying numbers..." and return 48.0.

Solução

solution.cpp

solution.cpp

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

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

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

Awesome!

Completion rate improved to 7.69

bookChallenge: Math Operation Handler

Deslize para mostrar o menu

Tarefa

Swipe to start coding

You're building a simple math operation processor that performs different calculations based on the selected operation type.

Use a switch statement to handle each operation type.

  1. Addition (case 1)
    • Add a and b.
    • Print "Adding numbers...".
  2. Subtraction (case 2)
    • Subtract b from a.
    • Print "Subtracting numbers...".
  3. Multiplication (case 3)
    • Multiply a by b.
    • Print "Multiplying numbers...".
  4. Division (case 4)
    • Check if b is not equal to zero.
    • If true, divide a by b and print "Dividing numbers...".
    • Otherwise, print "Error: Division by zero not allowed.".
  5. Default Case
    • Print "Invalid operation type." if the number doesn't match any valid case.
  6. Return the result of the performed operation.

Example

operationType = 3, a = 12.0, b = 4.0 => "Multiplying numbers..." and return 48.0.

Solução

solution.cpp

solution.cpp

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 3
single

single

some-alt