Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Hello, C++! | Getting Started with C++
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
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.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

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.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1
some-alt