From 97217b687c733aaa5de1cb297cb92b0b69c0f12a Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 19:20:11 +0000 Subject: [PATCH] Added graph mode for testing with basic sin function table --- src/main/c/main_taschenrechner.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 526d9e9..7645288 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -22,9 +22,10 @@ int divide(int a, int b) { return a / b; } +// // scientificmode -int scientificmode(){ +int scientificMode(){ double num, result; @@ -62,6 +63,25 @@ int scientificmode(){ return result; } +// graphMode +void graphMode() { + double x, y; + + printf("Enter the range for x (start end step): "); + double x_start, x_end, x_step; + scanf("%lf %lf %lf", &x_start, &x_end, &x_step); + + printf("\nGraph for the function y = sin(x):\n"); + + printf(" x\t| y\n"); + printf("--------------\n"); + + for (x = x_start; x <= x_end; x += x_step) { + y = sin(x); + printf("%.2lf\t| %.2lf\n", x, y); + } +} + // change mode int mode(int userChoice){