How use this in calculator ? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
- 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"); }

18th Feb 2022, 8:09 AM
BABLU TAUNWAL
BABLU TAUNWAL - avatar
4 Réponses
+ 1
You need to put that code in main function. This way it won't work.
18th Feb 2022, 8:35 AM
Ipang
+ 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 👍
18th Feb 2022, 12:35 PM
Ipang
+ 1
Ok thanks Ipang
18th Feb 2022, 12:41 PM
BABLU TAUNWAL
BABLU TAUNWAL - avatar