#include int add ( int x, int y ); /* Add y to x */ int sub ( int x, int y); /* Subtracts y from x */ int mult ( int x, int y ); /* Multiplies x with y */ int div ( int x, int y ); /* Divides x with y */ int main() { int input; int x; int y; printf( "CALCULATOR\n" ); printf( "\n" ); printf( "What do you want to do ?\n" ); printf( "1. Add\n" ); printf( "2. Extract\n" ); printf( "3. Multiply\n" ); printf( "4. Divide\n" ); printf( "5. Exit\n" ); printf( "Selection: " ); scanf( "%d", &input ); switch ( input ) { case 1: /* When 1 is chosen call add function */ printf( "Please input two numbers to be added to eachother: \n" ); scanf( "%d", &x ); scanf( "%d", &y ); printf( "The result is: %d\n", add( x, y ) ); break; case 2: /* When 2 is chosen call substract function */ printf( "Please input two numbers to be extracted from eachother: \n" ); scanf( "%d", &x ); scanf( "%d", &y ); printf( "The result is: %d\n", sub( x, y ) ); break; case 3: /* When 3 is chosen call multiply function */ printf( "Please input two numbers to be multiplied: \n" ); scanf( "%d", &x ); scanf( "%d", &y ); printf( "The result is: %d\n", mult( x, y ) ); break; case 4: /* When 4 is chosen call divide function */ printf( "Please input two numbers to be divided: \n" ); scanf( "%d", &x ); scanf( "%d", &y ); printf( "The result is: %d\n", div( x, y ) ); break; case 5: /* When 5 is chosen stop the program */ printf( "Shutting Down...\n" ); break; default: printf( "Bad input, quitting!\n" ); break; } getchar(); return 0; } int add (int x, int y) { return x + y; } int sub (int x, int y) { return x - y; } int mult (int x, int y) { return x * y; } int div (int x, int y) { return x / y; }