0

What is the problem of this code

#include <stdio.h> void main() { float a,b; char op; int answer; printf("Enter the your first value\n"); scanf("%f",&a); printf("Enter the your first value\n"); scanf("%f",&b); printf("Enter the your Operation"); scanf("%c",&op); switch (op) { case "+": answer(a+b); break; case "-": answer(a-b); break; case "*": answer(a*b); break; case "/": answer(a/b); break; } }

21st Nov 2020, 1:51 PM
Rana Naskar
Rana Naskar - avatar
2 odpowiedzi
+ 2
You ask "Enter the your first value" two times.
21st Nov 2020, 2:46 PM
Ipang
+ 1
Use single quotes for charecters.. Double quotes are used for strings... Print result.. And take answer as float type as well otherwise you miss fraction part.. Edit : Rana Naskar Oh. Why dublicate? answer(a+b) this is calling function 'answer' by a+b value.. Where is answer function? In other question answer=a+b is fine. https://www.sololearn.com/Discuss/2597975/?ref=app
21st Nov 2020, 2:14 PM
Jayakrishna 🇮🇳