raja.krishnan3 - please do not hijack someone else's thread. Prefer to start a new thread of your own.
Before posting again please read and comply with the forum rules and posting guideines.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.