A very easy problem for all novice programmers...get your hands dirty...
Read this post on petrushkagoogol2.blogspot.com