Copyright © Programs ++
Design by Dzignine
Wednesday, 11 January 2012

"Hello World" C++ Program

Printing a message on the console output window is one of the most basic program that is taught while starting with c++. Below i have written two versions of the "Hello World" C++ program, one as per the standards of GCC compiler package, and one in turbo C++ which, even though redundant, is taught in many schools and colleges when students learn basics of c++.
Note : Regardless of the compiler package used, the output is the same.:)

1 -Standard Version (complied with gcc compiler package)
// "Hello World " C++ program (standard version)

#include <iostream>

int main()
{
     std::cout<<" Hello World";
     std::cin.get(); // to keep the console from closing down immediately
     return 0;
}

Note: If the console window closes immediately, then add std::cin.get(); before return 0; to fix the problem. :)
2 - Non standard version ( for turbo c++ and similar compilers )

// "Hello World" in C++ (non-standard)

#include<iostream.h>
#include<conio.h>
using namespace std;
int main
    cout<<" Hello World "; 
    getch(); // prevents the console window from closing immediately
    return 0; 

"Hello Wold" C++ Program

1 comments:

  1. Pls Note that it is important to include the



    for getche()

    function to work in the non standerd version...
    this was the mistake that i kept on doing repeatedly...

    ReplyDelete

Comment Here....