Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 02 / Solutions / task6.cpp
blob: a7484b2189e9c0ea3bc2ee37dbf6b85eea472444 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
using namespace std;
int main()
{
	 double a, b;
	 char operation;

	 cout << "Enter the first number: ";
	 cin >> a;

	 cout << "Enter the second number: ";
	 cin >> b;

	 cout << "Choose operation: +, -, / or *: ";
	 cin >> operation;

	 switch (operation)
	 {
	 case '+':
		  cout << "Result: " << a + b << endl;
		  break;
	 case '-':
		  cout << "Result: " << a - b << endl;
		  break;
	 case '*':
		  cout << "Result: " << a * b << endl;
		  break;
	 case '/':
		  if (b < 0.0000001)
		  {
				cout << "You can not divide by zero!\n";
				return 1;
		  }
		  cout << "Result: " << a / b << endl;
		  break;
	 default:
		  cout << "Invalid operation!\n";
		  break;
	 }

	 return 0;
}