|
@ -5,6 +5,14 @@ |
|
|
|
|
|
|
|
|
#include "taschenrechner.h" |
|
|
#include "taschenrechner.h" |
|
|
|
|
|
|
|
|
|
|
|
// get the NUmbers from the user |
|
|
|
|
|
int getIntegerInput(const char* prompt) { |
|
|
|
|
|
int num; |
|
|
|
|
|
printf("%s", prompt); |
|
|
|
|
|
scanf("%d", &num); |
|
|
|
|
|
return num; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Calculation |
|
|
// Calculation |
|
|
int performOperation(int num1, char operator, int num2) { |
|
|
int performOperation(int num1, char operator, int num2) { |
|
|
switch (operator) { |
|
|
switch (operator) { |
|
@ -31,14 +39,12 @@ void programmingMode() { |
|
|
int num1, num2, result; |
|
|
int num1, num2, result; |
|
|
char operator; |
|
|
char operator; |
|
|
|
|
|
|
|
|
printf("Enter first integer: "); |
|
|
|
|
|
scanf("%d", &num1); |
|
|
|
|
|
|
|
|
num1 = getIntegerInput("Enter first integer: "); |
|
|
|
|
|
|
|
|
printf("Enter operator (+, -, *, /): "); |
|
|
printf("Enter operator (+, -, *, /): "); |
|
|
scanf(" %c", &operator); |
|
|
scanf(" %c", &operator); |
|
|
|
|
|
|
|
|
printf("Enter second integer: "); |
|
|
|
|
|
scanf("%d", &num2); |
|
|
|
|
|
|
|
|
num2 = getIntegerInput("Enter second integer: "); |
|
|
|
|
|
|
|
|
// Calculation + Display the result |
|
|
// Calculation + Display the result |
|
|
|
|
|
|
|
|