Calculator program

question:https://hack.codingblocks.com/contests/c/509/195
Answer:https://ide.codingblocks.com/#/s/27001

what is wrong in this code

Your logic is slightly wrong.
You need to take input of the numbers n1 and n2 only if the user inputs some valid operator like,
+, -, *, /, %.
You are taking input of numbers when user enters X or x also. This is wrong. Try rectifying it.

Modifying that way also doesn’t work https://ide.codingblocks.com/#/s/27335

Can someone comment where my mistake is ?

https://ide.codingblocks.com/#/s/27980

i removed the last two lines, as i dnt know what they were doing and it worked. take n1 and n2 long long as range of number is 10^6 i guess and multiplying 1000000*1000000=10^12 which exceeds integer range.

1 Like

Thank you that was helpful

1 Like