PROBLEM:
Write a program to display the text, This is my first program, on the screen.
SOLUTION:
The program must start with #include
The main body of the program is contained within curly braces which follow the keyword main().
The text is displayed on the screen using the cout statement. Note that this statement requires a semi--colon at the end to indicate the end of the statement.
Comments have also been included to make the programme easier to understand.
// My first program
// Written by jmb
// October 1998
#include <iostream.h>
main()
{
cout << "This is my first program \n";
// \n is required to produce newline
}
Back to Main Page for Lecture 1 |