0

Look like your program needs input?? I'm getting this error message asking me to split the input

#include <stdio.h> int main() { char op; double first, second; printf("Enter an operator (+, -, *, /): "); scanf("%c", &op); printf("Enter two operands: "), scanf("%lf %lf", &first, &second); switch (op) { case '+': printf("%.1lf + %.1lf = %.1lf" = first, second, first + second); break, case '-': printf("%.1lf - %.1lf = %.1lf" = first, second, first - second); break, case '*': printf("%.1lf * %.1lf = %.1lf" = first, second, first * second); break, case '/': printf("%.1lf / %.1lf = %.1lf" = first, second, first / second); break, // operator doesn't match any case constant default: printf("Error! Operator is not correct"); } Return 0, }

26th Sep 2022, 1:07 PM
Richard Adu
3 Antworten
+ 1
You have to give all the inputs at runtime each break statement ends with semicolon instead of comma your printer statement inside switch case replace equals with comma
26th Sep 2022, 1:21 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
#include <stdio.h> int main() { char op; double first, second; printf("Enter an operator (+, -, *, /): "); scanf("%c", &op); printf("Enter two operands: "), scanf("%lf %lf", &first, &second); switch (op) { case '+': printf("%.1lf + %.1lf = %.1lf" , first, second, first + second); break; case '-': printf("%.1lf - %.1lf = %.1lf" , first, second, first - second); break; case '*': printf("%.1lf * %.1lf = %.1lf" , first, second, first * second); break; case '/': printf("%.1lf / %.1lf = %.1lf" , first, second, first / second); break; // operator doesn't match any case constant default: printf("Error! Operator is not correct"); } return 0; }
26th Sep 2022, 1:20 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Thanks, I do appreciate your efforts to help me out
27th Sep 2022, 7:13 PM
Richard Adu