|
Main in itself doesn't do anything to calculate the area. It CALLS A FUNCTION to do that. The function is Area. It does the work. It accepts a length and a width and returns the product of those (the area). One could calculate it directly in main, but the lesson is showing you that it's better to do it with a function. If you need to do it 73 times, you call the function 73 times instead of having to replicate its entire body of code 73 times. That isn't too bad for the area function, a single multiplication, but consider if it were a very complex calculation.
The prototype at the top is not for you; it's for the compiler. Now it can tell if "main" called it correctly, because its pattern exists before the call. One doesn't have to prototype it. One could put the actual definition above main and the definition would let the compiler know that "main" called it properly. Most likely, though, for organizational reasons, you would like to have "main" at the top. Normally, with lots of functions to let the compiler know about, one would put the prototypes in a header file so they didn't visually clutter up the source file.
Now about those code tags.........THEY ARE SO DAMNED MUCH EASIER THAN PROGRAMMING!!!! put [/code] below your code block and [code] above your code block. I list them in reverse order here to prevent them from working in this example.
|