Unit#1 Basic Elements of a C++ Program | ||
|
||
|
||
|
You can first view the video and then read the material of this subsection, or you can first read the material. This video was filmed in Mohler 355/356 which is the usual classroom for the on campus version of this course. Content was designed
and prepared by Nonglak Phetkong and Jacob Kazakia, both of whom appear
in the video. Taping and editing was done by Steven Lichak of Lehigh University
Media Productions. Bill Mitchell facilitated the streaming and Robin Deily
designed the web presentation. |
|
As we saw earlier in Unit0, in order to "run" a program, we first create a text file with certain instructions ( style and readability require that these instructions are entered one per line ). Then this text file ( the source file) is processed by a compiler which generates another file called the executable. In a windows environment, clicking on the executable results into the execution of the program. The simplest structure needed in a source file is: #include<iostream.h> main( ) { ……….. ……….. } The first line lets the compiler know that there will be certain instructions requesting the reading of data through the keyboard and that there may also be some output to a default MSDOS window. It "includes" the input output stream header. The line main( ) signifies the start of the main function ( we will later see that a program may have many more functions). EVERY PROGRAM MUST HAVE A MAIN FUNCTION. The contents of the function, i.e. the various instructions, go in between the curly brackets. NOTE: In some cases you may see a specification attached before the word main, such as int main( ) or void main( ) , don't worry about this. We will use main( ) for the time being. Read your book and try to explain the action requested by the following statements:
Don't worry about the specific details at this point. As we move along, we will be discussing the above items in more detail. |
||
Jacob
Y. Kazakia © 2001 All rights reserved
|