Docstoc

anatomy_of_cpp_program_lesson

Document Sample
anatomy_of_cpp_program_lesson Powered By Docstoc
					Programming
COP 1000
Class lesson 2
Anatomy of a C++ Program


No audio
No video


                           1
2
        Answer to 14a&b

start
         get value1
         get value2
         answer = value1 + value2
         print answer
stop




                                    3
  Anatomy of C++

Structure of a C++ Program



                             4
    C++ Source Code
#include <iostream.h>

using namespace std;

int main (int argc, char *argv[])
{
  cout << "This program was compiled using\n";
  cout << "Colossal C++ version 2.5.\n";

    system("PAUSE");
    return EXIT_SUCCESS;
}



                                                 5
Parts of the Source Code
    Comments
    Compiler directives
    The main Function
    Braces
    Statements
    Semicolons
    C++ and blank space
    Uppercase and lowercase

                              6
                    C++ Program
// Title: Demo of a simple program
// Purpose: Allow students to see the basic
//           parts of a C++ program
// By Ric French

#include <iostream.h>                         // load library
using namespace std;                          // compiler directive

int main (int argc, char *argv[ ])           // starts the main function
{                                            // begins the block of code
  cout << "This program was compiled using\n"; //print to screen

    cout << "Colossal C++ version 2.5.\n";    // print to screen

    system("PAUSE");                          // compiler directive
    return EXIT_SUCCESS;                      // ends the main function
}                                             // ends the block of code


                                                                           7
// Title: Demo of a simple program
// Purpose: Allow students to see the basic                     Indicates a
//           parts of a C++ program
// By Ric French                                                 comment
                                                        Compiler
#include <iostream.h>                               // load library
using namespace std;                                     directive
                                                    // compiler directive

int main (int argc, char *argv[ ])
                                                               The main
                                                    // starts the main function
{                                                   // begins the block of code
  cout << "This program was compiled using\n";
                                                                function
                                                    //print to screen

    cout << "Colossal C++ version 2.5.\n";          // print to screen

    system("PAUSE");                                // compiler directive
    return EXIT_SUCCESS;                            // ends the main function
}                                                   // ends the block of code


                                                          Braces

                                              Semicolon
                                                                         8
9

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:5
posted:9/26/2012
language:Unknown
pages:9