about main | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

about main

where main function will be stored and executed?

16th Sep 2017, 10:07 AM
anwesh jami
anwesh jami - avatar
1 Answer
0
I'm not 100% sure I understand what you're asking, but basically, the main() function is the very heart and soul of your C++ program. Other functions can be defined outside of main() within your program, but only the code within the main function will be executed. For example: #include <iostream> using namespace std; void hello() { cout << "Hello, world!"; } int main() { hello(); return 0; } // Outputs "Hello, world!" In the above code, function hello() is defined but not executed until it is called within function main(). Everything that is to be executed will be within the main() function. I hope that this answer clears up your confusion, and please, be more clear and concise with what you are asking in the future.
16th Nov 2017, 3:47 PM
Spencer Smith
Spencer Smith - avatar