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

#include<iostream>
 
using namespace std;
 
int main()
{
    cout << "Hello World\n";
    return 0;
}

C++ hello world class program

#include<iostream>
 
using namespace std;
 
// Creating class
 
class Message
{
  public:
 
    void display() {
      cout << "Hello World\n";
    }
};
 
int main()
{
    Message c;    // Creating an object
    c.display();  // Calling the function
 
    return 0;
}