MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / main8

Function main8

Lab_03/Operators.cpp:7–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <iostream>
6using namespace std;
7int main8() {
8 char op;
9 float num1, num2;
10 cout << "Enter the 1st operand: ";
11 cin >> num1;
12 cout << "Enter operator either + or - or * or / : ";
13 cin >> op;
14 cout << "Enter 2nd operand: ";
15 cin >> num2;
16 cout << endl;
17 switch (op)
18 {
19 case '+':
20 cout << "Result is "<< num1 + num2 << endl;
21 break;
22 case '-':
23 cout << "Result is " << num1 - num2 << endl;
24 break;
25 case '*':
26 cout << "Result is " << num1 * num2 << endl;
27 break;
28 case '/':
29 cout << "Result is " << num1 / num2 << endl;
30 break;
31 default:
32 cout << "Error! Operator is not correct";
33 break;
34 }
35 system("pause");
36 return 0;
37}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected