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; } }
2 Réponses
+ 2
You ask "Enter the your first value" two times.
+ 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