Creating a C++ Program

We are going to create our first C++ program. At the command line type "emacs Hello_World.cpp" to open your program. This program is going to read two lines from standard in, average them, and output the result.

Remember the outline of a C++ program:

#include<iostream>
using namespace std;

int main() {

	return 0;
}
You will add code to the outline above to make it work as described. The following code (extracted from Lecture 2) contains examples of how to do input and output from a C++ program:

Compiling and Running

To compile, we use the command "g++ -Wall Hello_World.cpp -o Hello_World.out".

To run, use "./Hello_World.out".