Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Switch Calculator | Conditional Control Flow Practice
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C Conditional Statements

bookChallenge: Switch Calculator

Завдання

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.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 2
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

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

bookChallenge: Switch Calculator

Свайпніть щоб показати меню

Завдання

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.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 2
single

single

some-alt