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.:)
// "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 )
Note : Regardless of the compiler package used, the output is the same.:)
1 -Standard Version (complied with gcc compiler package)
#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
#include<conio.h>
using namespace std;
int main
cout<<" Hello World ";
getch(); // prevents the console window from closing immediately
getch(); // prevents the console window from closing immediately
return 0;
}
}
"Hello Wold" C++ Program |
Pls Note that it is important to include the
ReplyDeletefor getche()
function to work in the non standerd version...
this was the mistake that i kept on doing repeatedly...