Hello World C++ Example Program

Major Parts In C++ Program

  • Part 1: Header File or Preprocessor Section and Namespace declaration
  • Part 2: Global Variables or Global Functions  // Optional
  • Part 3: Class declaration   // Optional
  • Part 4: Main Function of C++

for better understanding,

Syntax for Simple C++ Program

// Header files

//Standard namespace declaration
// Global Variables or Functions

//Main Function
int main()
{
     // Main Function Code 
     return 0;
}

Simple 'Hello World' C++ Program

/*  Example Program For Hello World In C++
    little drops @ thiyagaraaj.com

    Coded By: THIYAGARAAJ MP             */

// Header Files
#include<iostream>
#include<conio.h>

//Standard namespace declaration
using namespace std;

//Main Function
int main()
{
     //Standard Ouput Statement
     cout<<"Hello World";
     // Wait For Output Screen
     getch();
     //Main Function return Statement
     return 0;
}

Sample Output

Hello World