|
@ -7,7 +7,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void programmingMode() { |
|
|
void programmingMode() { |
|
|
|
|
|
|
|
|
int num1, num2, result; |
|
|
int num1, num2, result; |
|
|
char operator; |
|
|
char operator; |
|
|
|
|
|
|
|
@ -20,4 +19,30 @@ void programmingMode() { |
|
|
printf("Enter second integer: "); |
|
|
printf("Enter second integer: "); |
|
|
scanf("%d", &num2); |
|
|
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); |
|
|
} |
|
|
} |