Hello World in C++

Prestashop 1.5 features for developers (Part-1 Modules)
datatypes in C++

hello_world The Hello world program is a simple computer program that prints (or displays) the string “Hello, world!” or some variant thereof. It is typically one of the simplest programs possible in almost all computer languages, and often used as first program to demonstrate a programming language. As such it can be used to quickly compare syntax differences between various programming languages.This is a simple hello world application code in C++.it is the first basic program to show some text on the console window. This code will print a “hello world” application on the console window.

  2.     // A simple hello wold C++ program
  3.     #include<iostream>
  4.     using namespace std;
  5.     int main()    //main function starts here.
  6.     {
  7.         //hello world statement is mentioned here
  8.         cout<<“hello world “<<endl;    
  10.         return 0;            //ending main function
  11.     }

Now let’s explain the code:

The “//” is called a comment, its not the part of the code, it is just used as a hint for the coder that provides an easiness to study and search inside the code.
Now the “ #include<iostream >” is called a preprocessor directive. Lines that begin with # are processed by the preprocessor before the program is compiled. This line notifies the preprocessor to include in the program the contents of the input/output stream header <iostream>. This header must be included for any program that outputs data to the screen or inputs data from the keyboard using C++’s stream input/output.
Now “ int main() ” is a function which is an important part of every C++ program, The parentheses after main indicate that main is a program building block called a function. After a little bit of learning C++ you will be able to create your own functions.
“ cout ”means console output, it is used to print the text inside the  “”  on the console window, as shown in the code.
“endl” means end line. This is used to move to the next line.
The “ return 0 ” statement shows that program ended successfully.
Remember that every code statement in the C++ ends with the “ ; ” which is also called a terminator.
So it was the first basic program to print a hello world on the screen, i hope it wasn’t difficult.

Prestashop 1.5 features for developers (Part-1 Modules)
datatypes in C++

Leave a Reply