+ 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

20th Dec 2021, 10:10 AM
Hemasri Kottapalli
Hemasri Kottapalli - avatar
3 Answers
+ 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.
20th Dec 2021, 12:40 PM
SoloProg
SoloProg - avatar
+ 1
THANK YOU!! I updated as you said but still I'm facing problems in taking operator input. SoloProg
20th Dec 2021, 12:59 PM
Hemasri Kottapalli
Hemasri Kottapalli - avatar
+ 1
LearneršŸŽ– I tryed your code above. And for me it's working. Example : 5 [ENTER] / [ENTER] 5 [SUBMIT] Result => 1.0000
20th Dec 2021, 1:52 PM
Coding Cat
Coding Cat - avatar