Browse Source

Implement trigonometric functions in scientific calculator.

remotes/origin/kabrel
fdai7782 11 months ago
parent
commit
d67b4dae4c
  1. 30
      src/main/c/scientificMode.c

30
src/main/c/scientificMode.c

@ -1,8 +1,8 @@
// scientificMode // scientificMode
#include <stdio.h>
#include <math.h>
#include "taschenrechner.h" #include "taschenrechner.h"
#include <math.h>
#include <stdio.h>
int scientificMode() { int scientificMode() {
@ -35,13 +35,35 @@ int scientificMode(){
break; break;
case 4: // Trigonometric case 4: // Trigonometric
result = sineFunction(num);
printf("Trigonometric functions:\n");
printf("5: Sine\n");
printf("6: Cosine\n");
printf("7: Tangent\n");
int trigChoice;
scanf("%d", &trigChoice);
switch (trigChoice) {
case 5: // Sine
result = sin(num);
break;
case 6: // Cosine
result = cos(num);
break;
case 7: // Tangent
result = tan(num);
break; break;
default: default:
printf("Invalid choice. Please try again.\n");
printf("Invalid trigonometric function choice.\n");
return -1; // Return an error code to indicate failure return -1; // Return an error code to indicate failure
}
break;
default:
printf("Invalid choice. Please try again.\n");
return -1; // Return an error code to indicate failure
} }
printf("Result: %lf\n", result); printf("Result: %lf\n", result);

Loading…
Cancel
Save