Please forgive me if my lack of formal programming education is the real trouble, but I see problems being asked on the board now and then where part of the problem states to call a function to do something that I can do as part of one line of code.
If one line of code can be used within main() to determine some result, would it still be "better" or perhaps more "proper" to send out to a function?
As an example, the recent post "coin flip in C++" states "the program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads."
If I write this program with a function called flip, I have to add several lines. If I omit the need for the function flip, I can calculate the answer in one line plus the printf/cout line.
Is the need for a separate function just a part of this class structure at this point in its schedule or is it more proper to perform everything in separate functions? Would I be a problem student in this class?:-)
Comments please. Thanks.
0 · ·