Last active
May 23, 2018 20:13
-
-
Save devmike01/5a4f80c09e13e9e782bec723740265cd to your computer and use it in GitHub Desktop.
Simple Calculator
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
// ConsoleApplication1.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int _tmain() | |
{ | |
//assign an identifier for the numbers | |
float num1, num2, result; | |
char oper; | |
//the user input | |
cin >> num1 >> oper >> num2; | |
//Display line | |
cout << "*********************************************************" << endl; | |
//Check the user operator | |
if(oper == '+'){ | |
result = num1 + num2; | |
}else if(oper == '-'){ | |
result = num1 - num2; | |
} | |
else if(oper == '/'){ | |
result = num1 / num2; | |
} | |
else if(oper == '*'){ | |
result = num1 * num2; | |
} | |
else{ | |
cout << "Invalid operations...Please press enter to exit" << endl; | |
} | |
cout << result << endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment