here are the preserved indentations.
Code:
#include <iostream.h>
#include <ctype.h>
#include <stdlib.h>
float c;
//function declarators//
float add(float, float);
float sub(float, float);
float mul(float, float);
float div(float, float);
//function definitions//
//Here is says the following
//'c' undeclared (first use this function)
float add(float a, float b) {
c = a + b;
cout << "Sum = >" << c;
return(c);
}
float sub(float a, float b) {
c = a - b;
cout << "Difference = >" << c;
return(c);
}
float mul(float a, float b) {
c = a * b;
cout << "Product = >" << c;
return(c);
}
float div(float a, float b) {
c = a / b;
cout << "Qoutient = >" << c;
return(c);
}
main() {
float a, b; //global variables//
char choice;
cout << "\t Simple Calculator - Ver. 1.0 02-03 EDT." << endl;
cout << "\t Author: -[[email protected]]-" << endl << endl;
do {
cout << " Select Option [1 - 5]" << endl;
cout << " [1] Addition" << endl;
cout << " [2] Subtraction" << endl;
cout << " [3] Multiply" << endl;
cout << " [4] Divide" << endl;
cout << " [5] Exit" << endl;
cout << " Enter Selection Num. >";
cin >> choice;
cout << endl;
//switch statements//
switch (choice) {
case '1' : {
system ("PAUSE");
cout << endl;
cout << " 2 Digits, Enter ->";
cin >> a >> b; cout << endl;
cout << add(a, b);
break; }
case '2' : {
system ("PAUSE");
cout << endl;
cout << " 2 Digits, Enter ->";
cin >> a >> b; cout << endl;
cout << sub(a, b);
break; }
case '3' : {
system ("PAUSE");
cout << endl;
cout << " 2 Digits, Enter ->";
cin >> a >> b; cout << endl;
cout << mul(a, b);
break; }
case '4' : {
system ("PAUSE");
cout << endl;
cout << " 2 Digits, Enter ->";
cin >> a >> b; cout << endl;
cout << div(a, b);
break; }
case '5' : {
cout << endl;
cout << " Selection 5: (Exit);" << endl;
cout << " Simple Calculator Ver 1.0" << endl;
cout << " Developed By: -[[email protected]]-" << endl;
system ("PAUSE");
exit(0);
break; }
default : { cout << "Invalid Selection\n"; main(); }
} while ((choice != '0') && (choice != '6'));
return(0);
}}