|
@ -14,17 +14,17 @@ void BasicMode() { |
|
|
|
|
|
|
|
|
do { |
|
|
do { |
|
|
//100 doubles in this array goes through the for loop till 100 numbers or = is entered |
|
|
//100 doubles in this array goes through the for loop till 100 numbers or = is entered |
|
|
for (int i = 0; i < 100) { |
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
printf("Enter a Number: "); |
|
|
printf("Enter a Number: "); |
|
|
numbers[i] = testForNumber(); //gets number |
|
|
numbers[i] = testForNumber(); //gets number |
|
|
|
|
|
|
|
|
printf("Enter a operation: "); |
|
|
printf("Enter a operation: "); |
|
|
operators[i] = testForOperator(); //gets operator |
|
|
operators[i] = testForOperator(); //gets operator |
|
|
} |
|
|
} |
|
|
} while (endtmp != '1') |
|
|
|
|
|
|
|
|
} while (endtmp != '1'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 100) {//checks all operators to check for priority |
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++) {//checks all operators to check for priority |
|
|
if ((operators[i] == '/' || operators[i] == '*') && i > 1) { //if operators[i] == / or * and i>1 so you dont get numbers[-1] |
|
|
if ((operators[i] == '/' || operators[i] == '*') && i > 1) { //if operators[i] == / or * and i>1 so you dont get numbers[-1] |
|
|
if (operators[i] == '/') { |
|
|
if (operators[i] == '/') { |
|
|
result += divide(numbers[i - 1], numbers[i]); //divides if char is / and adds number to the result |
|
|
result += divide(numbers[i - 1], numbers[i]); //divides if char is / and adds number to the result |
|
@ -45,12 +45,12 @@ void BasicMode() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else if (i<=1 && operator[i] == '=') { //if there are less then 2 numbers in the array |
|
|
|
|
|
|
|
|
else if (i<=1 && operators[i] == '=') { //if there are less then 2 numbers in the array |
|
|
result = numbers[i]; //set result to the 0 digit |
|
|
result = numbers[i]; //set result to the 0 digit |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else if (operator[i] == '=') { //if char is = |
|
|
|
|
|
printf("The result is: %d", result); //print out the result |
|
|
|
|
|
|
|
|
else if (operators[i] == '=') { //if char is = |
|
|
|
|
|
printf("The result is: %f", result); //print out the result |
|
|
i = 100; |
|
|
i = 100; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|