-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from Jethendra-17/patch-1
Create #75
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include<iostream> | ||
using namespace std; | ||
|
||
int main() { | ||
int num1, num2; | ||
char operation; | ||
|
||
cout << "Enter first number: "; | ||
cin >> num1; | ||
|
||
cout << "Enter operator (+, -, *, /): "; | ||
cin >> operation; | ||
|
||
cout << "Enter second number: "; | ||
cin >> num2; | ||
|
||
switch(operation) { | ||
case '+': | ||
cout << "Result: " << num1 + num2 << endl; | ||
break; | ||
case '-': | ||
cout << "Result: " << num1 - num2 << endl; | ||
break; | ||
case '*': | ||
cout << "Result: " << num1 * num2 << endl; | ||
break; | ||
case '/': | ||
if(num2 != 0) | ||
cout << "Result: " << num1 / num2 << endl; | ||
else | ||
cout << "Error! Division by zero is not allowed."; | ||
break; | ||
default: | ||
cout << "Invalid operator!"; | ||
break; | ||
} | ||
|
||
return 0; | ||
} |