usually you will not get the source code here, because the most people has no interest to write some program that is simple but cost some time. When you have already written some, then we would like to see it and tell you the problem that you have done. Or you ask us an very interest problem so that we would also like to solve it.
your problem this one is not difficult, and you can usually find the demo code somehing alike in most c++ book, for example: <<c++ primer plus>> The author of this book names Prata.