Procedural: Hello, World!Trail Index | Procedural | Hello World /** * Hello World * structure, main, includes, output */ // include standard input/output streams for C++ #include <iostream> /** * main function */ int main() { /* * lines inside a function should be indented * to improve readability */ std::cout << "Hello, World!" << std::endl; // output to terminal return 0; // zero means all is well } /* * multi-line * comment * until closed with */ /* single-line comment, until */ // single-line comment, until the end of line Comments, in slightly varied forms. #include <iostream>
int main() { This is the declaration of an executable routine, or function, which is assigned
the name By a common convention, the "main" function is the point from which the execution of a program starts; so all executable programs need to have a "main" routine. Still by convention, main is expected to return a value, which must be zero when the program has executed correctly, and non-zero if some error occurred. std::cout is the standard console output stream. It's the way C++ represents that odd Terminal thing, in practice. << "Hello, world!"
<< std::endl is a "end of line" being sent into the console output stream. The semicolon is very important: it separates one instruction from the other. identifies the end of the body of the routine. < Procedural | Trail Index | Variables > |