#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
char op;
float num1, num2, res;
clrscr();
printf("Enter first number:\n");
scanf("%f", &num1);
printf("Enter second number:\n");
scanf("%f", &num2);
printf("Operation(+,-,*,/):\n);
fflush(stdin);
scanf("%c",&op);
switch(op)
{
case '+':
{
res = num1 + num2;
break;
}
case '-':
{
res = fabs(num1 - num2);
break;
}
case '*':
{
res = num1 * num2;
break;
}
case '/':
{
res = num1 / num2;
break;
}
default
{
printf("Invalid choice");
}
printf("Result::%f", res);
getch();
}
Output:
Enter first number:
28
Enter second number:
7
Operation(+,-,*,/):
/
Result::4.000000