Download presentation
Presentation is loading. Please wait.
Published byCorey Moody Modified over 9 years ago
1
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming
2
Starting Out with C++, 3 rd Edition 2 1.1Why Program? Computers can do many different jobs because they are programmable.
3
Starting Out with C++, 3 rd Edition 3 1.2Computer Systems: Hardware and Software All computer systems consist of similar hardware devices and software components. This section provides an overview of standard computer hardware and software organization.
4
Starting Out with C++, 3 rd Edition 4 Hardware 1.The CPU 2.Main Memory 3.Secondary Storage 4.Input Devices 5.Output Devices
5
Starting Out with C++, 3 rd Edition 5 Input Device Central Processing Unit Main Memory Output Device Output Device Figure 1.1
6
Starting Out with C++, 3 rd Edition 6 Figure 1.2 Arithmetic and Logic Unit Control Unit Instruction (Input) Result (Output)
7
Starting Out with C++, 3 rd Edition 7 Software –Operating Systems Single tasking Multi-tasking –Application Software
8
Starting Out with C++, 3 rd Edition 8 1.3Programs and Programming Languages What is a program? –A set of instructions a computer follows in order to perform a task. A programming language is a special language used to write computer programs.
9
Starting Out with C++, 3 rd Edition 9 Program 1-1 // This program calculates the user’s pay. #include void main(void) { float hours, rate, pay; cout << “How many hours did you work? ”; cin >> hours; cout << “How much do you get paid per hour? ”; cin >> rate; pay = hours * rate; cout << “You have earned $” << pay << endl; }
10
Starting Out with C++, 3 rd Edition 10 Program Output How many hours did you work? 10 How much do you get paid per hour? 15 You have earned $150
11
Starting Out with C++, 3 rd Edition 11 Programming Languages High level (Close to Human Language) Low level (Machine Language) Figure 1-4
12
Starting Out with C++, 3 rd Edition 12 Table 1-1
13
Starting Out with C++, 3 rd Edition 13 1.4 What is a Program Made of? There are certain elements that are common to all programming languages. –Key Words –Programmer-Defined Symbols –Operators –Punctuation
14
Starting Out with C++, 3 rd Edition 14 Language Elements, Table 1-2
15
Starting Out with C++, 3 rd Edition 15 Lines and Statements cout << “How many hours did you work?”;
16
Starting Out with C++, 3 rd Edition 16 Variables A storage location in the computer’s memory for holding a piece of information. Symbolic names that represent locations in the computer’s random-access memory.
17
Starting Out with C++, 3 rd Edition 17 Variable Declarations Two types of information: numbers and characters Numbers may be integers or floating-point numbers The statement below creates three variables in memory named hours, rate, and pay that each can store a floating point number float hours, rate, pay;
18
Starting Out with C++, 3 rd Edition 18 1.5 Input, Processing, and Output Input: cin >> hours; Processing: pay = hours * rate; Output cout<<“You have earned $”<<pay;
19
Starting Out with C++, 3 rd Edition 19 1.6The Programming Process The programming process consists of several steps, which include design, creation, testing and debugging activities.
20
Starting Out with C++, 3 rd Edition 20 Designing and Creating a Program 1. Clearly define what the program is to do 2. Visualize the program running on the computer. 3. Design a flowchart or hierarchy chart 4. Check the flowchart or hierarchy chart for logical errors.
21
Starting Out with C++, 3 rd Edition 21 5. Write a pseudocode version of the program. 6. Check the pseudocode for errors. 7. Write the actual program on paper. 8. Desk-check the program for errors. 9. Enter the code and compile it. 10. Correct any errors found during compilation. Repeat steps 9 and 10 as many times as necessary.
22
Starting Out with C++, 3 rd Edition 22 11. Run the program with test data for input. 12.Correct any errors found while running the program. Repeat steps 9 through 12 as many times as necessary. 13.Validate the results of the program.
23
Starting Out with C++, 3 rd Edition 23 1.7 Procedural and Object-Oriented Programming Procedural programming and object- oriented programming are two ways of thinking about software development and program design.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.