Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.

Similar presentations


Presentation on theme: "Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition."— Presentation transcript:

1 Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition

2 Introduction to Programming with C++, Fourth Edition2 Objectives Code an algorithm into a program Desk-check a program Evaluate and modify a program Differentiate among source code, object code, and executable code Understand the components of a C++ program

3 Introduction to Programming with C++, Fourth Edition3 Objectives (continued) Create a Visual C++.NET solution, project, and source file Open a Visual C++.NET solution Save, build, and execute a C++ program Locate an error in a C++ program Make a backup copy of a solution

4 Introduction to Programming with C++, Fourth Edition4 More on the Problem-Solving Process

5 Introduction to Programming with C++, Fourth Edition5 Coding the Algorithm into a Program

6 Introduction to Programming with C++, Fourth Edition6 Coding the Algorithm into a Program (continued) IPO chart shows: –Input, processing, and output items –Algorithm needed to solve the problem The algorithm shows the steps to calculate and display Sarah’s new weekly pay The calculation is based on the current weekly pay and raise rate values entered by the user Algorithm also calculates an intermediate value, weekly raise

7 Introduction to Programming with C++, Fourth Edition7 Coding the Algorithm into a Program (continued)

8 Introduction to Programming with C++, Fourth Edition8 Assigning Names, Data Types, and Initial Values to the IPO Items Assign a descriptive name to each unique input, processing, and output item listed in the IPO Be aware of naming rules Assign a data type to each input, processing, and output item Assign an initial value

9 Introduction to Programming with C++, Fourth Edition9 Assigning Names, Data Types, and Initial Values to the IPO Items (continued)

10 Introduction to Programming with C++, Fourth Edition10 Translating the Algorithm Steps into C++ Code

11 Introduction to Programming with C++, Fourth Edition11 Desk-Checking the Program

12 Introduction to Programming with C++, Fourth Edition12 Desk-Checking the Program (continued)

13 Introduction to Programming with C++, Fourth Edition13 Desk-Checking the Program (continued)

14 Introduction to Programming with C++, Fourth Edition14 Desk-Checking the Program (continued)

15 Introduction to Programming with C++, Fourth Edition15 Desk-Checking the Program (continued)

16 Introduction to Programming with C++, Fourth Edition16 Evaluating and Modifying the Program Debugging - the process of locating and removing any errors, called bugs, in a program Program errors can be either syntax errors or logic errors You create a syntax error when you enter an instruction that violates the programming language’s syntax

17 Introduction to Programming with C++, Fourth Edition17 Evaluating and Modifying the Program (continued) Logic errors - much more difficult to find because they can occur for a variety of reasons and do not trigger an error message from the compiler

18 Introduction to Programming with C++, Fourth Edition18 Creating a C++ Program C++ evolved from the procedure-oriented C programming language, which was developed in 1972 at Bell Laboratories by Dennis Ritchie In 1985, Bjarne Stroustrup (Bell Laboratories) added object-oriented features to C C++ is a superset of C Source code - C++ instructions Source file – contains the source code

19 Introduction to Programming with C++, Fourth Edition19 Creating a C++ Program (continued) Object code - the 0s and 1s that the computer can understand Object file - the file containing the object code Linker - combines the object file with other machine code necessary for your C++ program to run correctly Executable file - contains all of the machine code necessary to run your C++ program

20 Introduction to Programming with C++, Fourth Edition20 Process by which Source Code is Translated into Executable Code

21 Introduction to Programming with C++, Fourth Edition21

22 Introduction to Programming with C++, Fourth Edition22 Creating a C++ Program Comment (internal documentation) - a message to the person reading the program Function - a block of code that performs a task Void functions – do not return values after completing their assigned tasks Function header - marks the beginning of the function Function body - everything between the opening and closing braces

23 Introduction to Programming with C++, Fourth Edition23 Summary After analyzing a problem, code the algorithm into a program Desk-check the program to verify that the algorithm was correctly translated Evaluate and modify if necessary Program errors can be either: –Syntax: violate a rule of the language –Logic: error in the algorithm

24 Introduction to Programming with C++, Fourth Edition24 Summary (continued) To create and execute a C++ program, you need to have a text editor and a C++ compiler Source code is C++ instructions you enter The compiler translates source code into machine code, or object code Linker produces an executable file containing all of the machine code to run your C++ program

25 Introduction to Programming with C++, Fourth Edition25 Summary (continued) Programs have various components: –Comments –Directives –using statements –Functions


Download ppt "Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition."

Similar presentations


Ads by Google