I think you haven't understood the question. I can help you out with a basic layout. Try more and then let us know when you are stuck.
1. Before writing your program, understand the requirements first. If this step is skipped, then you will face numerous difficulties when you actually code.
2. Having understood the requirements, prepare your formulae or logic required. Write them down it helps.
3. By the time you start coding, you must have a thorough understanding of what you need to do or you will only end up writing random code or code which doesn't serve your purpose.
Here's a little pseudo code to help you get started:
#include (include your header files here)
int main ()
{
}
return_type function_name(enter the parameter variable here)
{
}
You can use this to start off.