1 Chapter 1: Introduction to Computers, Problem Solving, and ProgrammingAbstraction, and Design using C++ 6e by Frank L. Friedman and Elliot B. Koffman
2 Algorithms C++ Linux Codewarrior
3 Early Computers Late 1930’s, John Atanasoff, Clifford Berry ENIAC 1946University of Pennsylvania J. Presper Eckert and John Mauchley John von Neumann, stored-program concept
4 Categories of ComputersSupercomputers Mainframe Minicomputers Microcomputers
5 Figure (a) Notebook Computer (HP Pavilion dv5©, Courtesy of Hewlett-Packard). (b) Palmtop Computer (iPhone 3G©, Courtesy of Apple, Inc.) (c) Desktop Computer (iMac©, Courtesy of Apple, Inc.)
6 Computer Hardware CPU - central processing unit Main MemoryWhere decisions are made, computations are performed, and input/output requests are delegated Main Memory Stores information being processed by the CPU Secondary Memory (Mass Storage) Stores data and programs
7 Computer Hardware Input devices Output devices Network connectionAllow people to supply information to computers Output devices Allow people to receive information from computers Network connection Modems Ethernet interface
8 Figure 1.3 Components of a Computer
9 Memory Stores Types Composed of bits, which are combined into bytesprograms operating system applications data Types RAM - volatile ROM Composed of bits, which are combined into bytes
10 Memory Cells Address Contents -27.2 1 2 354 3 4 0.005 5 6 -26 . . .1 2 3 4 5 6 . . . 999 -27.2 354 0.005 -26 H RTV 001 . . . X 75.62
11 Figure 1.5 Relationship Between a Byte and a Bit
12 Secondary Memory Semi permanent data-storage capabilityMagnetic Hard disk Floppy disk Tape Non-magnetic CD or DVD memory stick, flash drive Secondary memory usually has much more storage capacity than main memory
13 Figure 1.6 Secondary Storage Media
14 CPU “Brains” of the computerArithmetic calculations are performed using the Arithmetic/Logical Unit or ALU Control unit decodes and executes instructions Registers hold information and instructions for CPU to process Arithmetic operations are performed using binary number system
15 Figure The Intel Atom processor chip contains the full circuitry of a central processing unit in an integrated circuit whose small size and low power requirements make it suitable for use in mobile internet devices. (Intel Corporation Pressroom Photo Archives)
16 Input / Output Devices Accessories that allow computer to perform specific tasks Receiving information for processing Return the results of processing Common input and output devices Keyboard Joystick Scanner Printer Monitor Speaker
17 Computer Networks Allows multiple computers to connect together to share resources and/or data LAN - Local area network Organizational WAN - Wide area network Internet Requires additional hardware modem network interface
18 Figure 1.7 Local Area Network
19 Figure 1.8 A Wide Area Network with Satellite Relays of Microwave Signals
20 World Wide Web Introduced 1989 Developed by CERN Web browserEuropean Laboratory for Particle Physics Web browser GUI Netscape IE
21 1.3 Computer Software Operating system Other system softwareutilities programming language systems Applications
22 Operating System E.g. Windows®, Unix® Controlsthe interaction of system with the user hardware interactions Part is usually stored on ROM, rest on hard drive This arrangement requires booting the system
23 Some OS ResponsibilitiesCommunicating with the user; receiving user commands Managing allocation of memory, processor time, file system, and other resources Collecting input from keyboard, mouse, etc. Conveying output to screen, printer, etc. Writing data to secondary storage devices
24 Figure 1.9 Entering a UNIX Command for Directory Display
25 Figure 1.10 Accessing Secondary Storage Devices through Windows
26 Application Software Does the “real” work Common application softwareWord processors Desktop publishing programs Spreadsheets Presentation managers Drawing programs
27 Programming LanguagesMachine Language Most fundamental language of the computer Unique for each processor type Binary 0s and 1s that specify what to do
28 Table 1.2 A Program in Machine and Assembly Language
29 High - Level Languages Resemble human languageC++, C, Pascal, FORTRAN, Ada a = a + b; More compact and human understandable than machine language Must be translated into machine language
30 Object Oriented ProgrammingC++ derived from C by Bjarne Stroustrup Popular because of reuse Classes Objects Methods Organized in a Hierarchy Super Classes Sub Classes
31
32 Object Oriented DesignAbstraction Extract the relevant properties of an object while ignoring inessential details Encapsulation Breaking down an object into parts, hiding and protecting its essential information, and supplying an interface to modify the information in a controlled and useful manner
33 1.4 Processing a High-Level Language ProgramSet of programs used to develop software A key component is a translator Compiler Examples g++, Borland C++®, Microsoft Visual C++® Other programs needed Editor Linker Loader
34 Processing a Program Editor used to enter the programLike minimal word processor Creates source program file Compiler translates the source program Displays syntax errors Creates (usually) temporary object code file Linker/Loader to combine object file with other object files and execute program Creates final executable program
35 Executing a Program CPU Special instructions used toexamines each program instruction in memory sends out command signals required to carry out the instruction Special instructions used to input data into memory for the program to use output data to display or printer (or other device)
36 Figure 1.11 Entering, Translating, and Running a High-Level Language Program
37 Figure 1.12 Flow of Information During Program Execution
38 1.5 Software Development MethodProblem Analysis Identify data objects Determine Input / Output data Constraints on the problem Design Decompose into smaller problems Top-down design (divide and conquer) Develop Algorithm (Desk check) Algorithm refinement
39 Software Development MethodImplementation Converting the algorithm into programming language Testing Verify the program meets requirements System and Unit test Maintenance All programs undergo change over time
40 1.6 Applying the Software Development MethodCase Study: Converting Miles to Kilometers Problem Your summer surveying job requires you to study some maps that give distances in kilometers and some that use miles. You and your coworkers prefer to deal in metric measurements. Write a program that performs the necessary conversion.
41 Case Study Analysis The first step in solving this problem is to determine what you are asked to do. You must convert from one system of measurement to another, but are you supposed to convert from kilometers to miles, or vice versa? The problem states that you prefer to deal in metric measurements, so you must convert distance measurements in miles to kilometers.
42 Data Requirements Problem Input miles distance in miles Problem Outputkms the distance in kilometers Relevant Formula 1 mile = kilometers
43 Design Formulate the algorithm that solves the problem. Algorithm1. Get the distance in miles. 2. Convert the distance to kilometers. 3. Display the distance in kilometers. Algorithm Refinement 2.1 The distance in kilometers is the distance in miles Desk check!
44 Listing 1.2 Miles to kilometers
45 Implementation #include
46 Testing Test with input data for which you can easily determine the expected results E.g. 10 miles should convert to kilometers
47 1.7 Professional Ethics for Computer ProgrammersPrivacy and Misuse of Data Computer Hacking Plagiarism and Software Piracy Misuse of a Computer Resource