|
@ -4,6 +4,41 @@ |
|
|
#include <math.h> |
|
|
#include <math.h> |
|
|
#include "taschenrechner.h" |
|
|
#include "taschenrechner.h" |
|
|
|
|
|
|
|
|
|
|
|
// Logarithm |
|
|
|
|
|
void executeLogarithmFunction(double num) { |
|
|
|
|
|
int logChoice; |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
|
printf("Logarithm Options:\n"); |
|
|
|
|
|
printf("1: Logarithm (base 10)\n"); |
|
|
|
|
|
printf("2: Natural Logarithm (ln)\n"); |
|
|
|
|
|
printf("3: Logarithm (base 2)\n"); |
|
|
|
|
|
printf("0: Exit Logarithm Menu\n"); |
|
|
|
|
|
scanf("%d", &logChoice); |
|
|
|
|
|
|
|
|
|
|
|
switch (logChoice) { |
|
|
|
|
|
case 1: // Logarithm (base 10) |
|
|
|
|
|
printf("Result: %lf\n", logarithmFunction(num)); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: // Natural Logarithm (ln) |
|
|
|
|
|
printf("Result: %lf\n", naturalLogarithmFunction(num)); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: // Logarithm (base 2) |
|
|
|
|
|
printf("Result: %lf\n", logarithmBase2Function(num)); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 0: // Exit the logarithm menu |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
printf("Invalid logarithm function choice. Please try again.\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} while (logChoice != 0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int scientificMode(){ |
|
|
int scientificMode(){ |
|
|
|
|
|
|
|
|
double num, result; |
|
|
double num, result; |
|
@ -37,37 +72,7 @@ int scientificMode(){ |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 3: // Logarithm |
|
|
case 3: // Logarithm |
|
|
do { |
|
|
|
|
|
printf("Logarithm Options:\n"); |
|
|
|
|
|
printf("1: Logarithm (base 10)\n"); |
|
|
|
|
|
printf("2: Natural Logarithm (ln)\n"); |
|
|
|
|
|
printf("3: Logarithm (base 2)\n"); |
|
|
|
|
|
printf("0: Exit Logarithm Menu\n"); |
|
|
|
|
|
scanf("%d", &logChoice); |
|
|
|
|
|
|
|
|
|
|
|
switch(logChoice) { |
|
|
|
|
|
case 1: // Logarithm (base 10) |
|
|
|
|
|
result = logarithmFunction(num); |
|
|
|
|
|
printf("Result: %lf\n", result); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: // Natural Logarithm (ln) |
|
|
|
|
|
result = naturalLogarithmFunction(num); |
|
|
|
|
|
printf("Result: %lf\n", result); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: // Logarithm (base 2) |
|
|
|
|
|
result = logarithmBase2Function(num); |
|
|
|
|
|
printf("Result: %lf\n", result); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 0: // Exit the logarithm menu |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
printf("Invalid logarithm function choice. Please try again.\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} while (logChoice != 0); |
|
|
|
|
|
|
|
|
executeLogarithmFunction(num); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 4: // Trigonometric |
|
|
case 4: // Trigonometric |
|
|