#include <cstdlib> #include <iostream> #include "output.cpp" // This source file includes the functions that prompt for number entry upon selection. #include "algorithm.cpp" // This source file contains math functions to do addition, multiplication, etc. using namespace std; int main () { int Oper; cout << "Please select an operations:\n"; cout << "1. Addition\n"; cout << "2. Subtraction\n"; cout << "3. Multiplication\n"; cout << "4. Division\n"; cout << "\nChoice: "; cin >> Oper; cout << endl; switch(Oper) { case 1: addout(); // addout(), subout(), etc are the functions included in output.cpp addition(); // addition(), subtraction(), etc are the functions included in algorithm.cpp break; case 2: subout(); subtraction(); break; case 3: multout(); multiplication(); break; case 4: divout(); division(); break; default: "You have chosen an incorrect choice."; } system("PAUSE"); return 0; } |
include <iostream> using namespace std; int total = 0; // The value to hold the answer to the equation. const int MAX = 10; // This constant is the max input allowed of the user. int numArray[ MAX ]; // This is the array that user input will be placed into, it will allow for 10 numbers only. int i = 0; // This is the variable that will be used to gather input from user, and place input into an numArray. double addition() // The addition function will add user input, allowing decimals. { do{ cin >> numArray[ i ]; total += numArray[ i ]; i++; }while(i < 10); cout << "\n" << total << endl << endl; // Returns the sum of the numbers entered in the array. return 0; } double subtraction() { do{ cin >> numArray[ i ]; total -= numArray[ i ]; i++; }while(i < 10); cout << "\n" << total << endl << endl; return 0; } double multiplication() { do{ cin >> numArray[ i ]; total *= numArray[ i ]; i++; }while(i < 10); cout << "\n" << total << endl << endl; return 0; } double division() { do{ cin >> numArray[ i ]; total /= numArray[ i ]; i++; }while(i < 10); cout << "\n" << total << endl << endl; } |
Don't include cpp files. You link to them, you don't include them. Read this: http://cplusplus.com/forum/articles/10627/ |