mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-10 03:06:58 +02:00
Update 102-first-program.md
Added additional information about the functions and return values about the program.
This commit is contained in:
@@ -27,7 +27,7 @@ The first line of the program `#include <iostream>` is a [preprocessor directive
|
|||||||
|
|
||||||
## `main()` Function
|
## `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
|
```cpp
|
||||||
int main() {
|
int main() {
|
||||||
@@ -42,7 +42,7 @@ To output text to the console, we use the `std::cout` object and the insertion o
|
|||||||
```cpp
|
```cpp
|
||||||
std::cout << "Hello, World!" << std::endl;
|
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
|
- `std::cout`: The standard "character output" stream that writes to the console
|
||||||
- `"Hello, World!"`: The string literal to print
|
- `"Hello, World!"`: The string literal to print
|
||||||
- `std::endl`: The "end line" manipulator that inserts a newline character and flushes the output buffer
|
- `std::endl`: The "end line" manipulator that inserts a newline character and flushes the output buffer
|
||||||
|
Reference in New Issue
Block a user