- 1
How use this in calculator ?
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"); }
4 Réponses
+ 1
You need to put that code in main function. This way it won't work.
+ 1
BABLU TAUNWAL
I read your message, but can't respond in DM.
If you want to make an online calculator then you need to learn web development with HTML, CSS and JS.
I suggest you to search Code Playground for web projects with calculator ideas and learn from the codes 👍
+ 1
Ok thanks Ipang
- 1