@TheIdeasMan
Do not use goto - forget it even exists. Your usage was to exit the program. If you want to print messages and then exit, put into a function. |
I will keep that in mind. I don't know why I've never thought of that...
Avoid using infinite loops. There are valid places to use them, but this isn't one of them. |
I have never really thought about this before...I do know the danger of infinite loops, so I'll be changing to what you have suggest.
I think you need to make more use of functions - your runmath function is 160 lines long. Candidates for functions are the body of loops, and long if or else if clauses. Also look out for repetitive code |
I have been trying very hard to put them into functions, but I'm not really good with it right now...When the code was first completed, everything was being stick together... I guess I'll work harder on my logic part on breaking things down. I'll keep an eye out for repeaters.
Thanks for the suggestion, I'll work on it.
With the bracket counting, you could increment for left brackets and decrement for right brackets. Then if bracketcount is not zero there is an error. |
I did coded this way at first, but then I realized that I needed a counter, which is why I've done it this way...I guess my logic is a bit limited, which is why i've done it the "bad" way...
Does the divide function check for division by zero? |
I did think about this, but then, when I was running the program, it seems to print out "inf" which I think it means infinite...so I didn't really look into it. I think I was being lazy....
---------------------------
* Welcome to my Calculator*
* To leave type "exit" *
* Type when ready *
---------------------------
1/0
divi func a: 1 b: 0
inf
Answer: inf |
Thank you very much for your reply. It does open up some new doors to me and I'll be sure to look through those points.
Thank you again.
Edit--------------------------------------------
Just checked my code, it wasn't working with equation like this "1+(2+(3+4))". I have fixed it and updated my code above.
I won't be updating suggestion made by testers yet. I want to have different viewers giving different suggestion from the same piece of code.
However, do note that all suggestion are being taken seriously and I'll be doing changes at my end.
Once again, thank you all for reading this and helping me out. I very much appreciate it.