0

It will probably be covered in a later lesson, but shouldn't variables be declared before the main () function?

14th Nov 2016, 4:28 AM
Josh Cammack
Josh Cammack - avatar
2 odpowiedzi
+ 4
it is sometimes considered bad practice to declare variables before main(), and is those variables called global variables. the main concern with them, is you have limited control over them, and basically every function which is declared on the same code file is able to make changes to them.
14th Nov 2016, 6:28 AM
Burey
Burey - avatar
+ 1
Variable scoping wasn't discussed prior. Furthermore, scoping is irrelevant in trivial examples like these unless the intent is to illustrate scoping in some degree (I.e. difference between local/global, etc.).
14th Nov 2016, 4:42 AM
Gregory F Martin