c++ echo hello world code example

Example 1: hello world c++

#include <iostream>


int main(){
 std::cout <<"Hello World" << std::endl;
 return 0;
}

Example 2: c++ hello world

#include <iostream>

int main()
{
  std::cout << "Hello, C++!" << std::endl;
  return 0;
}

Example 3: print hello world c++

#include <iostream> 
using namespace std;
main() {
  cout << "Hello world" << endl; 
}

Example 4: print hello world on c++

/*These are comments. They are used to assist the programmer.
They do not affect the program in any way.
Write whatever you want*/
#include <iostream> //preprocessor directive (use input/output)

using namespace std; //use standard definitions

//This is the "main" function. C++ will start executing code here
int main(){ //bracket signals the start of the main function
         cout << "Hello, world!" << endl; //display with a new line
         //main must return an integer. 0 means success, else fail
         return 0; 
} //end of the main function

Tags:

Cpp Example