Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Hello, C++! | Getting Started with C++
C++ FOundations: V1

bookHello, C++!

main.cpp

main.cpp

copy
1234567
#include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }

To understand how this simple C++ program works, start by looking at the first line: #include <iostream>. This line tells the compiler to include the standard input-output stream library, which provides the functionality for displaying output on the screen using std::cout.

Next, the line int main() { begins the definition of the main function. Every C++ program must have a main function, which is where the program starts executing. The int before main means that the function returns an integer value to the operating system when the program finishes.

Inside the curly braces { }, you find the statement std::cout << "Hello, World!" << std::endl;. Here, std::cout is the standard character output stream in C++. The << operator is used to send the string "Hello, World!" to the output stream. Adding << std::endl inserts a newline character so that any following output appears on the next line. This line is what actually prints Hello, World! to the console.

Finally, return 0; signals that the program finished successfully. The closing brace } marks the end of the main function. With these elements, you have a complete, functional C++ program that prints a message to the screen.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 1

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain what would happen if I removed `#include <iostream>`?

What does `return 0;` actually do in the program?

Can you show me how to modify this program to print a different message?

bookHello, C++!

Deslize para mostrar o menu

main.cpp

main.cpp

copy
1234567
#include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }

To understand how this simple C++ program works, start by looking at the first line: #include <iostream>. This line tells the compiler to include the standard input-output stream library, which provides the functionality for displaying output on the screen using std::cout.

Next, the line int main() { begins the definition of the main function. Every C++ program must have a main function, which is where the program starts executing. The int before main means that the function returns an integer value to the operating system when the program finishes.

Inside the curly braces { }, you find the statement std::cout << "Hello, World!" << std::endl;. Here, std::cout is the standard character output stream in C++. The << operator is used to send the string "Hello, World!" to the output stream. Adding << std::endl inserts a newline character so that any following output appears on the next line. This line is what actually prints Hello, World! to the console.

Finally, return 0; signals that the program finished successfully. The closing brace } marks the end of the main function. With these elements, you have a complete, functional C++ program that prints a message to the screen.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 1
some-alt