From eb61b94c137d38adc0812feacc7c788f7c30b937 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Mon, 5 Feb 2024 18:40:02 +0000 Subject: [PATCH] Implement basic scientific calculator functions. --- src/main/c/scientificMode.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/c/scientificMode.c b/src/main/c/scientificMode.c index 52ba133..b855139 100644 --- a/src/main/c/scientificMode.c +++ b/src/main/c/scientificMode.c @@ -4,7 +4,6 @@ #include #include "taschenrechner.h" - int scientificMode(){ double num, result; @@ -12,33 +11,39 @@ int scientificMode(){ int choice; printf("Enter a number: "); - scanf("%lf", &num); // scan the number from user - + printf("Scientific mode Options:\n"); - printf("1: Square root:\n"); - printf("2: Exponential:\n"); - printf("2: Logarithm:\n"); - printf("4: Trigonomertic"); + printf("1: Square root\n"); + printf("2: Exponential\n"); + printf("3: Logarithm\n"); + printf("4: Trigonometric\n"); scanf("%d", &choice); // user choice switch(choice) { case 1: // Square root - break; + result = squareRootFunction(num); + break; case 2: // Exponential - break; + result = exponentialFunction(num); + break; case 3: // Logarithm - break; + result = logarithmFunction(num); + break; + + case 4: // Trigonometric + result = sineFunction(num); + break; - case 4: // Trigonomertic - break; - - default: printf("Invalid choice. Please try again.\n"); + default: + printf("Invalid choice. Please try again.\n"); + return -1; // Return an error code to indicate failure } + printf("Result: %lf\n", result); return result; }