+ 2
Can you please help with this code's output?
I wanted to create a calculator which has a fault,and the fault is,it takes 1,2,3,4 inplace of 9,8,7,6 respectively! So I wrote this code but it's not taking operator input. Please let me know the reason, and kindly correct any other mistakes! https://code.sololearn.com/cTWdGj0B3FaH/?ref=app
3 Antworten
+ 3
some mistakes I found are:
scanf(" %c", &op); // Space is given before %c
You confused the regular slash and the backslash.
case '/':
ans=x/y;
break ;
int answer(int x,int y, char opr)
it should be float instead of integer as the result should be decimal in regards to the division operation within the function.
+ 1
THANK YOU!!
I updated as you said but still I'm facing problems in taking operator input. SoloProg
+ 1
Learner🎖 I tryed your code above. And for me it's working.
Example :
5 [ENTER]
/ [ENTER]
5 [SUBMIT]
Result => 1.0000