Prototyping and Clarity

Hello everyone, I just had a quick question up to this point in the course. I understand why we have to prototype our functions to get them to work, but I noticed Ben follows the rough format of:

FunctionPrototypes()

int main ()
{
FunctionCalls()
}

Functions()

My question is, is there anything wrong with doing the function declaration and prototyping above the “int main()” in the same spot so that we don’t have to use as many lines overall? Or is this considered sloppy or frowned upon?

For example, I wrote the following:

void PrintIntro()
{
steps
}

string GetGuessPrintGuess()
{
steps
}

int main()
{
Calls
}

I think this might be a question I answered on Udemy?

However the “issue” is that the order of where you define the functions matter without the prototypes since you can’t refer to something that hasn’t been declared yet.

Also as a preference since main is the start of it all most people find it easier to read.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms