Browse Source

Added functioninality in the programmingMode

remotes/origin/kabrel
fdai7782 11 months ago
parent
commit
17a672a58b
  1. 27
      src/main/c/programmingMode.c

27
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);
}
Loading…
Cancel
Save