From 71d68f6b050bac80ffb53e4ce0c08ace640ca4ad Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Tue, 6 Feb 2024 19:43:38 +0000 Subject: [PATCH] refactoring: Removed the intermediate 'result' variable and directly printed the output using the performOperation function. --- src/main/c/programmingMode.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/c/programmingMode.c b/src/main/c/programmingMode.c index 6a63556..e4c2b8d 100644 --- a/src/main/c/programmingMode.c +++ b/src/main/c/programmingMode.c @@ -44,16 +44,12 @@ int performOperation(int num1, char operator, int num2) { } void programmingMode() { - int num1, num2, result; - char operator; - num1 = getIntegerInput("Enter first integer: "); - operator = getOperatorInput(); - num2 = getIntegerInput("Enter second integer: "); + int num1 = getIntegerInput("Enter first integer: "); + char operator = getOperatorInput(); + int num2 = getIntegerInput("Enter second integer: "); // Calculation + Display the result - result = performOperation(num1, operator, num2); - - printf("Result: %d\n", result); + printf("Result: %d\n", performOperation(num1, operator, num2)); } \ No newline at end of file