course content

Course Content

C++ Introduction

Entry Point of a ProgramEntry Point of a Program

Every C++ program must have a main() function. The syntax of it looks like this:

  • int main(): the starting point of a program. It's called the main function, and it's where the program begins executing.
  • { }: curly braces define a block of code. Everything inside these braces belongs to the main function and is part of the program's logic.
  • return 0;: marks the end of the program and indicates that it ran successfully. The 0 means everything went well. If there were issues, this value might be different in the output.


The return 0; statement is optional at the end of the main function. If omitted, the compiler will automatically insert it.


What is the purpose of the main() function in a program?

Select the correct answer

Everything was clear?

Section 1. Chapter 3