From d781568f93686438724a77a8603d2a71943530e7 Mon Sep 17 00:00:00 2001 From: Rishabh Verma <87109274+rishabhv2003@users.noreply.github.com> Date: Tue, 6 Feb 2024 19:58:41 +0545 Subject: [PATCH] Update 102-first-program.md Added additional information about the functions and return values about the program. --- .../cpp/content/101-setting-up/102-first-program.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md b/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md index ffee59b44..8d6633b01 100644 --- a/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md +++ b/src/data/roadmaps/cpp/content/101-setting-up/102-first-program.md @@ -27,7 +27,7 @@ The first line of the program `#include ` is a [preprocessor directive ## `main()` Function -In C++, the `main()` function serves as the entry point of your program. The operating system runs your program by calling this `main()` function. It should be defined only once in your program and must return an integer. +In C++, the `main()` function serves as the entry point of your program. The operating system runs your program by calling this `main()` function. It should be defined only once in your program and must return an integer. The keyword `int` is the return type of this function which is an integer. Unlike C in C++ it is mandatory to have `int` as the return type for the `main` function. ```cpp int main() { @@ -42,7 +42,7 @@ To output text to the console, we use the `std::cout` object and the insertion o ```cpp std::cout << "Hello, World!" << std::endl; ``` - +- `std`: This is the namespace where C++ standard library entities (classes and functions) reside. It stands for "standard" and is an abbreviation for the Standard Template Library (STL). - `std::cout`: The standard "character output" stream that writes to the console - `"Hello, World!"`: The string literal to print - `std::endl`: The "end line" manipulator that inserts a newline character and flushes the output buffer @@ -55,4 +55,4 @@ Lastly, the `return 0;` statement informs the operating system that the program return 0; ``` -Now that you understand the basic components of a C++ program, you can write your first program, compile it, and run it to see the "Hello, World!" message displayed on the screen. \ No newline at end of file +Now that you understand the basic components of a C++ program, you can write your first program, compile it, and run it to see the "Hello, World!" message displayed on the screen.