#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
int operand1, operand2;
char oprtor;
printf("Enter the first number: ");
scanf("%d",&operand1);
printf("\nEnter the second number: ");
scanf("%d",&operand2);
printf("\nEnter operation: ");
scanf("%s",&oprtor);
switch (oprtor) {
case '+': //Addition
printf("%d %c %d = %d",operand1, oprtor, operand2, operand1 + operand2 );
break;
case '-': // Subtraction
printf("%d %c %d = %d",operand1, oprtor, operand2, operand1 - operand2 );
break;
case '*': //Multiplication
printf("%d %c %d = %d",operand1, oprtor, operand2, operand1 * operand2 );
break;
case '/': //Division
printf("%d %c %d = %d",operand1, oprtor, operand2, operand1 / operand2 );
break;
case '%': // Modulo, display the Reamaider
printf("%d %c %d = remainder %d",operand1, oprtor, operand2, (operand1) % operand2 );
break;
default:
break;
}
getch();
}
0 comments:
Post a Comment