Code:
void Calc_Sales(void)
{char o='o';
int ch;
float num1,num2;
printf("Enter operator either + or - or * or divide : \n");
scanf(" %c", &ch);
printf("\nEnter two operands: ");
scanf("%f%f",&num1,&num2);
switch(o) {
case '+':
printf("%.1f + %.1f = %.1f",num1, num2, num1+num2);
break;
case '-':
printf("%.1f - %.1f = %.1f",num1, num2, num1-num2);
break;
case '*':
printf("%.1f * %.1f = %.1f",num1, num2, num1*num2);
break;
case '/':
printf("%.1f / %.1f = %.1f",num1, num2, num1/num2);
break;
default:
/* If operator is other than +, -, * or /, error message is shown */
printf("Error! operator is not correct");}
/* Flushes input buffer */
while ((ch = getchar()) != '\n' && ch != EOF) ;
printf("\n\nPress ENTER to continue.");
while ((ch = getchar()) != '\n' && ch != EOF);
getch();
}
This is actually a part of a program, whenever i input all the required values such as the operator and the operands, it gives the following error: "Operator is not correct"