1.2. Source Code Syntax Highlighting

C++ and Java code can be automatically syntax-highlighted.

#include <iostream>


/** An example of some C++ code
*/

using namespace std;

int main() {
  cout << "Hello world!" << endl;
  return 0;
}

You can also apply various highlighting and other formatting to the code.

#include <iostream>


/** An example of some C++ code
*/

using namespace std;

int main() {
  cout << "Hello world!" << endl;
  return 0;
}

You can also place callouts in the code

#include <iostream>


/** An example of some C++ code
*/

using namespace std;1

int main() {
  cout << "Hello world!" << endl;
  return 0;2
}

1

Without this, we would have to spell out some of the names in their long form: std::cout and std::endl.

2

main has a return type of int, so it must return a value. Zero is traditionally returned to indicate that the program has not encountered any problems.