Ok I am posting the code I did for questions 2,3 & 4. I don't know how to solve question 1. I did'nt implement any formulas in the code since I don't know, which is why the code is taking too much time. Also I haven't put wait ms function since my code was already too slow. I am posting these solutions to convince you guys that I have tried it and it is not the best solution, which is why I am asking for help. Also please don't comment on style guidelines because that is not the intend of posting these solution of mine.
I was able to solve a few other questions in Project Euler, but for these 4 questions I am unable to proceed. :smileyindifferent:
Thanks