Mr Rioch D'lyma,
I have gone through your code. It looks right. It is exactly as I have it here in my textbook on the subject although you have implemented the pseudocode using C++. You are also right in stating that IT DOES NOT GIVE THE RIGHT ANSWER ! You are right. IT DOES NOT ! I have been trying to run the program using Visual Basic.NET and I am getting different answers to a sample problem
provided in the book. Clearly, the book must be WRONG !
Have you been able to solve the problem now? If so let me know.