This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2024_Stanislav_Mykhailenko/Lesson_1/Task_4/main.cpp
Stanislav Mykhailenko 94ae06e975
Add Lesson 1
2024-06-04 11:40:07 +03:00

45 lines
1 KiB
C++

#include <iostream>
int main()
{
float firstNumber = 0;
float secondNumber = 0;
float result = 0;
char operation;
std::cout << "Enter the first number: ";
std::cin >> firstNumber;
std::cout << "Enter the second number: ";
std::cin >> secondNumber;
std::cout << "Enter operation: ";
std::cin >> operation;
switch (operation) {
case '+':
result = firstNumber + secondNumber;
break;
case '-':
result = firstNumber - secondNumber;
break;
case '*':
result = firstNumber * secondNumber;
break;
case '/':
if (secondNumber == 0) {
std::cout << "Division by zero" << std::endl;
return 1;
}
result = firstNumber / secondNumber;
break;
default:
std::cout << "Unknown operation." << std::endl;
return 2;
break;
}
std::cout << result << std::endl;
return 0;
}