Here, We are printing the Hello World using C++ program using cout function.
Here, We will write a simple program that will display Hello World message. We will discuss each part in detail.
using namespace std;
// This is the single comment
* multiple comment
cout << "Hello World" << endl;
The output of the above program is:
Let’s discuss all the lines of the above program in detail.
Here we can see two types of comments in the above program. Comments are the explanation or description of source code that does not affect your program logic in any way. Comments are neglected by compilers or interpreters.
// This is single line comments
* the multiple line comment.
This statement tells the compiler to include iostreamfile from the library. This library contains input-output functions such as cout, cin, etc.
The namespaceis a region that provides scope to an identifier (functions, variables, and name od the types). Here we have used std as namespacethat tells compiler to look into particular region of identifiers. I will not discuss this topic in details here beacause that may confuse you. We will learn this in details in next chapter with examples that helps you to make clear concept on namespace.
This is the mainfunction of our program from where the program start to execute. intmeans the return type of that function which tells the compiler that this function return integer type value.
coutis an object that is presented in iostrem class. The objective of this is to print the statement as a output. This object print inside the value include in double quote (“”) and it also can display variable values.
endlis an object of iostremclass which is used to print new line character.
This statement return 0 value from main function which state that execution is completed. return 1 state that execution is failed.
Get the latest tutorials, examples and projects updates.
We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.
Disable Ad Block
Want Same System