Basic Calculator

I am unable to find what is wrong with the code.
It is unable to pass the test cases.
Link for basic calculator: code:

Hello @shrey_sharma,

Please, read the input format clearly.
Your code will input only one symbol.
You are required to use the loop and take input inside.
And terminate the loop if input is ‘X’ or ‘x’.

Hope, this would help.
Let me know, if you still have any issue.
Give a like, if you are satisfied.

Hello @S18ML0016 ,
I have put the input function unside the loop.
But still it is giving a run time error on the test cases.
Kindly go through my new code.

LINK:https://ide.codingblocks.com/s/141031

Also please tell what should be done when second number is 0 in case of division as it is not specified in the problem statment

Thanks
Shrey

Hello @shrey_sharma,

  1. In the case when denominator is 0, print the appropriate message.
    It is not mentioned in the question because the question doesn’t demand you to consider this case.

  2. Runtime error can occur due to the following reasons:

    2.1. Invalid memory access during run-time.
    2.2. Accessing linked list nodes that do not exist.
    2.3. Dividing by zero.
    2.4. Large allocation of memory together/Large Static Memory Allocation.
    2.5. Making a silly mistake.

  3. You were required to break through the loop instead of returning random values.
    return statements will terminate the program.
    I have modified your code:
    https://ide.codingblocks.com/s/141044

Hope, this would help.
Give a like, if you are satisfied.

Hello I think my code works out correctly but still can’t get through test cases
i get this error on coding blocks ide…

source.cpp: In function ‘int main()’:
source.cpp:6:1: error: a function-definition is not allowed here before ‘{’ token
6 | {
| ^

But it works fine in my PC
Could you help me out @S18ML0016

Link to my code