Hello World Program In Cpp

Hello World:

The first thing to add to the source file is the main function. This is the entry point of the program, and the code inside of the curly brackets is what will be executed when the program runs. The brackets, along with their content, is referred to as a code block, or just a block.

Syntax
int main() {}

The first application will simply output the text “Hello World” to the screen. Before this can be done the iostream header needs to be included. This header provides input and output functionality for the program, and is one of the standard library files that come with all C++ compilers. What the #include directive does is effectively to replace the line with everything in the specified header before the file is compiled into an executable.

Syntax
#include <iostream>
int main() {}

With iostream included you gain access to several new functions. These are all located in the standard namespace called std, which you can examine by using a double colon, also called the scope resolution operator (::). After typing this in Visual Studio, the IntelliSense window will automatically open, displaying what the namespace contains. Among the members you find the cout stream, which is the standard output stream in C++ that will be used to print text to a console window. It uses two less-than signs known as the insertion operator (<<) to indicate what to output. The string can then be specified, delimited by double quotes, and followed by a semicolon. The semicolon is used in C++ to mark the end of all statements.

CODE/PROGRAM/EXAMPLE
#include <iostream>
int main()
  {
    std::cout << "Hello World";
  }

Using Namespace:

To make things a bit easier you can add a line specifying that the code file uses the standard namespace. You then no longer have to prefix cout with the namespace (std::) since it is now used by default.

CODE/PROGRAM/EXAMPLE
#include <iostream>
using namespace std;
int main()
  {
    cout << "Hello World";
  }

IntelliSense :

When writing code in Visual Studio, a window called IntelliSense will pop up wherever there are multiple predetermined alternatives from which to choose. This window can be also brought up manually at any time by pressing Ctrl+Space to provide quick access to any code entities you are able to use within your program. This is a very powerful feature that you should learn to make good use of.

#Hello_World_program_in_c++ #Hello_World_program_in_cpp #Using_Namespace_in_c++ #IntelliSense_in_c++

(New page will open, for Comment)

Not yet commented...