Write a code for a particular problem statement in any language as per your convenience, give various test cases as input for your code and test the output. Another way is to do lots of practice and only practice. Solve various problem statements and learn what is happening by tracing code or algorithm manually.