The <b>main()</b> Function




Document: Software Engineering 1: Lab Exercises

next Functional Decomposition
up Hints
gif Hints

The main() Function

Your main() function should declare variables to represent the values of all the relevant quantities. Think carefully about naming these variables - note, for example, that variable names cannot involve subscripts, or greek characters. Think carefully about the type of each variable: is it to be used to represent a numerical value? If so, will that value be strictly integral, or may it have a fractional part?

The overall structure of your main() function will consist of some initialisation (assigning initial values to appropriate variables), followed by a while loop which carries out the repeated calculations of the new and co-ordinate values. This loop should continue just so long as the value is greater than zero. The repetition, or iteration, in your program should be achieved using a while statement.

It might be a good idea to start off with a highly simplified version of the main() function, having only a variable to represent and which just (for example) decrements the value by a fixed amount each iteration. This would allow you to check, at this early stage, that you have correctly implemented the while loop and that it terminates when appropriate.




Document: Software Engineering 1: Lab Exercises

next Functional Decomposition
up Hints
gif Hints



McMullin@eeng.dcu.ie
Tue Apr 30 14:15:37 GMT 1996