From 17a672a58bc28fe553ea595587e0b4327b8423d9 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Tue, 6 Feb 2024 19:02:26 +0000 Subject: [PATCH] Added functioninality in the programmingMode --- src/main/c/programmingMode.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/c/programmingMode.c b/src/main/c/programmingMode.c index e89a75c..c869b99 100644 --- a/src/main/c/programmingMode.c +++ b/src/main/c/programmingMode.c @@ -7,7 +7,6 @@ void programmingMode() { - int num1, num2, result; char operator; @@ -20,4 +19,30 @@ void programmingMode() { printf("Enter second integer: "); scanf("%d", &num2); -} + // Calculation + switch (operator) { + case '+': + result = num1 + num2; + break; + case '-': + result = num1 - num2; + break; + case '*': + result = num1 * num2; + break; + case '/': + if (num2 != 0) { + result = num1 / num2; + } else { + printf("Error: Division by zero\n"); + result = 0; + } + break; + default: + printf("Invalid operator\n"); + result = 0; + } + + // Display the result + printf("Result: %d\n", result); +} \ No newline at end of file