+ 6
Hello, could you tell me the difference between the function declared outside main() and inside main()? Thanks in advance! 🙌🏻✨
For example: int square(int side); int main() { // Code } int square(int side){} ****Versus**** int main() { int square(int side); // Code } int square(int side){}
9 odpowiedzi
+ 8
Read the code and it's comment to see the difference.
https://code.sololearn.com/cjF9pRzhOkgX/?ref=app
+ 9
XXX Thank you so much! Got the point! 😄
+ 7
A function declared outside the main() function can be accessed outside the main() function.
https://code.sololearn.com/c9GwHJvW4q71/?ref=app
Whereas a function declared inside the main() function can *only* be used inside the main() function
https://code.sololearn.com/c43c85O5Lr0G/?ref=app
+ 6
Thanks RKK 🙌🏻 Got it!
+ 4
Martin Taylor I didn't understand why RKK ' s code is not an example of local function declaration.
+ 3
You're welcome Mahima Rajvir Singh :)