Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <ctype.h>
- #include <string>
- #include <array>
- using namespace std;
- int Addition(int x,int y);
- int Subtraction(int x,int y);
- int Multiplication(int x,int y);
- int Division(int x,int y);
- void main(){
- int x = 0;
- while( x == 0 ){
- int num1;
- string oper;
- int num2;
- cout << "******************************************" << endl;
- cout << "* Welcome to C++ Calculator *" << endl;
- cout << "* By *" << endl;
- cout << "* ryan7136 *" << endl;
- cout << "******************************************" << endl;
- cout << "* Please enter an operation: *" << endl;
- cout << "* Your choices are: *" << endl;
- cout << "* add, subtract, multiply, divide, pi, *" << endl;
- cout << "* and exit *" << endl;
- cout << "******************************************" << endl;
- getline(cin , oper);
- cin.clear();
- if(oper == "add"){
- cout << "Enter the first number:";
- cin >> num1;
- cout << "Enter the second number:";
- cin >> num2;
- cout << "The sum is: " << Addition(num1,num2) << "." << endl;
- }
- if(oper == "subtract"){
- cout << "Enter the first number:";
- cin >> num1;
- cout << "Enter the second number:";
- cin >> num2;
- cout << "The sum is: " << Subtraction(num1,num2) << "." << endl;
- }
- if(oper == "multiply"){
- cout << "Enter the first number:";
- cin >> num1;
- cout << "Enter the second number:";
- cin >> num2;
- cout << "The sum is: " << Multiplication(num1,num2) << "." << endl;
- }
- if(oper == "divide"){
- cout << "Enter the first number:";
- cin >> num1;
- cout << "Enter the second number:";
- cin >> num2;
- cout << "The sum is: " << Division(num1,num2) << "." << endl;
- }
- if(oper == "pi"){
- cout << "pi: 3.14159265358979323846264338327950288" << endl;
- }
- if(oper == "exit"){
- int x = 12;
- }
- system("CLS");
- }
- }
- int Addition(int x, int y){
- int answer;
- answer = x + y;
- return answer;
- }
- int Subtraction(int x, int y){
- int answer;
- answer = x - y;
- return answer;
- }
- int Multiplication(int x, int y){
- int answer;
- answer = x * y;
- return answer;
- }
- int Division(int x, int y){
- int answer;
- answer = x / y;
- return answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment