Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Entry Point of a Program | Getting Started
course content

Contenido del Curso

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.

Note

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?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 1. Capítulo 3
course content

Contenido del Curso

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.

Note

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?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 1. Capítulo 3
some-alt