The CODE: |
Information
about the code: |
//
Comments
at the beginning:
// your name
// a description of the program
// information pertinent to the program |
All programs should
begin with a comment identifying the programmer and the purpose of the program. |
#include <iostream.h>
#include <stdlib.h> |
Preprocessor directives begin with # and tell the computer to find
the filename that follows and read it in. The file
iostream.h
(Input/Output stream)
is used by cout.
The stdlib.h
is used to clear the screen.
Note:
<iostream.h>
should always be your first "header" file. |
int main(void) |
This
code begins the actual program. EVERY C++ program has a main( )
function. A function is a block of code that performs one or more
actions. While functions are usually called within a program, main(
) is called automatically. You may see various adaptations of this
line of code. While other adaptations are allowed, be sure to
maintain "int" as the return type because every ANSI-compliant C++
program will return zero to the IDE. |
{
system ("CLS");
cout<< "This is a literal print.\n";
cout<< "Yea!"<<endl;
return 0;
} |
Between the French curly
braces is the body of function
main( ). It is indented and terminates by returning 0 to the IDE.
This body:
* clears the screen,
* prints
This is a literal print.
Yea!
to the screen.
|