How can we input lots of inputs at a time https://online.codingblocks.com/player/7545/content/4806

my code take only 1 operation and two values at atime how i optimised it to accepect more then one output
https://ide.codingblocks.com/s/48514

Hey Ankush, this is calculator problem, in this there is no need to accept more than one input at a time, you can solve it by taking inputs one by one.

didi can yu tell me that why all test cases are not passes whereas my code is working perfectly fine

1 Like

Hey Ankush, your code is not working, it takes input only once, you are supposed to use a while loop to take the inputs until you get β€˜X’ or β€˜x’. for eg.
input:
*
1
2
+
2
3
X

your code’s output:
2

but the expected output:
2
5

showing time limit error https://ide.codingblocks.com/s/51675

Hi Ankush, try using a do while loop.

take input n1 and n2 only when you get a valid operator on input.Otherwise you will take wrong inputs, for eg.
input:
(
*
1
2
X

for this case your code will take input as
ch = {
n1 = *
n2 = 1

which will result in infinite loop as the termination condition will never be true.

in basic calculator https://online.codingblocks.com/player/7545/content/4806