Creating Computer Programs lesson 27. This lesson includes the following sections: What is a...
-
Upload
barnard-chandler -
Category
Documents
-
view
213 -
download
0
Transcript of Creating Computer Programs lesson 27. This lesson includes the following sections: What is a...
![Page 1: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/1.jpg)
Creating Computer Programs
lesson 27
![Page 2: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/2.jpg)
This lesson includes the following sections:
• What is a Computer Program? • How Programs Solve Problems
• Two Approaches: Structured & Object-Oriented Programming
![Page 3: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/3.jpg)
• Files
• Hardware/Software Interaction
What is a Computer Program?
![Page 4: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/4.jpg)
What is a Computer Program? - Files
Typically, a program is stored as a collection of files. Some common file types used in programs are:
• Executable (.EXE) files actually send commands to the processor.
• Dynamic Link Library (.DLL) files are partial .EXE files.
• Initialization (.INI) files contain configuration information for a program.
• Help (.HLP) files contain information for the user.
![Page 5: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/5.jpg)
• The program tells the CPU to process interrupts, or sets of steps the CPU must follow to perform a task.
• To control hardware, a program must be written in binary numbers (1s and 0s). This code is called machine code or machine language.
• Programmers use programming languages to write code in nearly human language. The resulting description is called source code.
• Compilers and interpreters translate a program into object code, the binary version of source code.
What is a Computer Program? - Hardware/Software Interaction
![Page 6: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/6.jpg)
• Program Control Flow
• Algorithms
• Heuristics
• Common Flow Patterns
• Variables and Functions
How Programs Solve Problems
![Page 7: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/7.jpg)
• The order in which program statements are executed is called program control flow.
• To determine program control flow, programmers may use a flowchart to map the program's sequence.
• Programmers may also create a simple text version of a program's code – called pseudocode – to determine how the program will flow.
How Programs Solve Problems – Program Control Flow
![Page 8: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/8.jpg)
This flowchartshows that thesequence canvary dependingon conditions.
![Page 9: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/9.jpg)
• An algorithm is a set of steps that always lead to a solution. The steps are always the same, whether the problem is being solved manually or with a PC.
• A computer program may contain thousands of algorithms, each one devoted to a single task.
• An algorithm, for example, will find the highest point in a mountain range by comparing all the points until the highest one is found.
How Programs Solve Problems - Algorithms
![Page 10: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/10.jpg)
no
![Page 11: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/11.jpg)
• If a problem is too complex to be solved by an algorithm, a programmer may try to solve it by using heuristics.
• Heuristics are like algorithms, and will always find a solution to a problem. But unlike algorithms, heuristics are not guaranteed to find the best possible solution.
• A heuristic, for example, may find the highest point in a mountain range by comparing random points, but this process may never find the highest one.
How Programs Solve Problems - Heuristics
![Page 12: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/12.jpg)
![Page 13: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/13.jpg)
• To determine when and where to pass program control, a developer may use conditional statements or loops.
• A conditional statement determines whether a condition is true. If so, control flows to the next part of the program.
• A loop repeats again and again until a condition is met. Control then passes to another part of the program.
How Programs Solve Problems - Common Flow Patterns
![Page 14: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/14.jpg)
![Page 15: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/15.jpg)
• A variable is a named placeholder for data that is being processed. Programs contain variables to hold inputs from users, for example.
• A function is a set of steps that are followed to perform a specific task. By assembling a collection of functions together, a developer can build a complete program.
How Programs Solve Problems - Variables and Functions
![Page 16: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/16.jpg)
• Structured programming
• Object-oriented programming
Early programmers allowed control to pass from one part of a program to another by using goto statements. Control would "go to" a different part of the program when conditions allowed.
Goto statements cause programs to become very complex. To eliminate their use, programmers developed two approaches to development:
Two Approaches: Structured & Object-Oriented Programming
![Page 17: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/17.jpg)
This type of programming has fallen into disfavor.
![Page 18: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/18.jpg)
• Sequence structure defines the default control flow.
• Selection structures are built around conditional statements.
• Repetition (looping) structures use loops, which execute according to the results of conditional statements.
Structured programming uses three types of control structures to make program control flow more predictable:
Two Approaches: Structured & Object-Oriented Programming - Structured Programming
![Page 19: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/19.jpg)
![Page 20: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/20.jpg)
• In object-oriented programming (OOP), programs are built from blocks of code, called objects. Each object has functions and characteristics (attributes), and can contain (encapsulate) other objects.
• Objects that share common attributes can be grouped into classes. Classes can be divided into subclasses.
• In OOP, objects communicate with one another by exchanging messages.
Two Approaches: Structured & Object-Oriented Programming - Object-Oriented Programming
![Page 21: Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:](https://reader035.fdocuments.in/reader035/viewer/2022070411/56649ccb5503460f94994099/html5/thumbnails/21.jpg)
• Define the term computer program.
• Describe the use of flowcharts and pseudocode in programming.
• Identify two ways in which a program can work toward a solution.
• Differentiate the two main approaches to computer programming.
• List and describe three elements of object-oriented programming.
lesson 27 Review