Browse Source

Implement trigonometric functions in scientific calculator.

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

34
src/main/c/scientificMode.c

@ -1,10 +1,10 @@
// scientificMode
#include <stdio.h>
#include <math.h>
#include "taschenrechner.h"
#include <math.h>
#include <stdio.h>
int scientificMode(){
int scientificMode() {
double num, result;
@ -20,7 +20,7 @@ int scientificMode(){
printf("4: Trigonometric\n");
scanf("%d", &choice); // user choice
switch(choice) {
switch (choice) {
case 1: // Square root
result = squareRootFunction(num);
@ -35,13 +35,35 @@ int scientificMode(){
break;
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;
default:
printf("Invalid choice. Please try again.\n");
printf("Invalid trigonometric function choice.\n");
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);

Loading…
Cancel
Save