You are here

C++ hello world program

C++ hello world program: C++ programming code to display hello world on the screen.

C++ hello world example

  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout << "Hello World\n";
  8.     return 0;
  9. }

C++ hello world class program

  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. // Creating class
  6.  
  7. class Message
  8. {
  9.   public:
  10.  
  11.     void display() {
  12.       cout << "Hello World\n";
  13.     }
  14. };
  15.  
  16. int main()
  17. {
  18.     Message c;    // Creating an object
  19.     c.display();  // Calling the function
  20.  
  21.     return 0;
  22. }