in dis program order() is declared inside main()....
My Question is:-
When order has a local scope in d second program because it is defined inside main(), so how come it is defined outside main()???
Because defining a function outside main() (or any function for dat matter inside which it has been declared) means dat it has a global scope, whereas we are declaring it inside main() meaning dat it has a local scope???????
The point of prototyping a function or class is so that the compiler knows it exists, even if it hasn't seen the definition. The first time you are globally prototyping the function, which means that anything defined after that prototype can use the order function without generating an error. In the second example, because you prototype the function in main, the prototype is only valid in the main function, which means that to call the order function from another function, you would either have to declare the prototype in the function that calls it, or the function would have to be defined after the order function. It's similar to a using declaration in this sense. For example this code would compile fine: