174x Filetype PDF File size 0.29 MB Source: websites.delta.edu
Objectives Programming Logic and In this chapter, you will learn about: Design • Computer systems • Simple program logic Sixth Edition • The steps involved in the program development Chapter 1 cycle • Pseudocode statements and flowchart symbols An Overview of Computers and • Using a sentinel value to end a program Programming • Programming and user environments • The evolution of programming models Programming Logic & Design, Sixth Edition 2 Understanding Computer Systems Understanding Computer Systems (continued) • Computer system • Programming – Combination of all the components required to – Writing software instructions process and store data using a computer • Computer hardware and software accomplish three • Hardware major operations – Equipment associated with a computer – Input • Software • Data items enter computer – Computer instructions – Processing – Tell the hardware what to do • By central processing unit (CPU) – Programs – Output • Instructions written by programmers Programming Logic & Design, Sixth Edition 3 Programming Logic & Design, Sixth Edition 4 Understanding Computer Systems Understanding Computer Systems (continued) (continued) • Programming language • Permanent storage devices – Use to write computer instructions – Nonvolatile – Examples • Compiler or an interpreter • Visual Basic, C#, C++, or Java – Translates program code into machine language • Syntax (binary language) – Rules governing its word usage and punctuation – Checks for syntax errors • Computer memory • Program executesor runs – Input will be accepted, some processing will occur, – Computer’s temporary, internal storage – Volatile and results will be output Programming Logic & Design, Sixth Edition 5 Programming Logic & Design, Sixth Edition 6 1 Understanding Simple Program Logic Understanding the Program Development Cycle • Program with syntax errors cannot execute • Program development cycle • Logical errors – Understand the problem – Errors in program logic – Plan the logic – Produce incorrect output as a result – Code the program • Logic of the computer program – Use software (a compiler or interpreter) to translate – Sequence of specific instructions in specific order the program into machine language • Variable – Test the program – Named memory location whose value can vary – Put the program into production – Maintain the program Programming Logic & Design, Sixth Edition 7 Programming Logic & Design, Sixth Edition 8 Understanding the Program Understanding the Problem Development Cycle (continued) • One of the most difficult aspects of programming • Usersor end users – People for whom program is written • Documentation – Supporting paperwork for a program Figure 1-1 The program development cycle Programming Logic & Design, Sixth Edition 9 Programming Logic & Design, Sixth Edition 10 Planning the Logic Coding the Program • Heart of the programming process • Hundreds of programming languages are available • Most common planning tools – Choose based on features – Flowcharts – Alike in their basic capabilities – Pseudocode • Easier than planning step • Desk-checking – Walking through a program’s logic on paper before you actually write the program Programming Logic & Design, Sixth Edition 11 Programming Logic & Design, Sixth Edition 12 2 Using Software to Translate the Using Software to Translate the Program into Machine Language Program into Machine Language (continued) • Translator program – Compiler or interpreter – Changes the programmer’s English-like high-level programming languageinto the low-level machine language • Syntax error – Misuse of a language’s grammar rules – Programmer corrects listed syntax errors – Might need to recompile the code several times Figure 1-2 Creating an executable program Programming Logic & Design, Sixth Edition 13 Programming Logic & Design, Sixth Edition 14 Testing the Program Putting the Program into Production • Logical error • Process depends on program’s purpose – Use a syntactically correct statement but use the – May take several months wrong one for the current context • Conversion • Test – Entire set of actions an organization must take to – Execute the program with some sample data to see switch over to using a new program or set of whether the results are logically correct programs • Programs should be tested with many sets of data Programming Logic & Design, Sixth Edition 15 Programming Logic & Design, Sixth Edition 16 Maintaining the Program Using Pseudocode Statements and Flowchart Symbols • Maintenance • Pseudocode – Making changes after program is put into production – English-like representation of the logical steps it • Common first programming job takes to solve a problem – Maintaining previously written programs • Flowchart • Make changes to existing programs – Pictorial representation of the logical steps it takes to – Repeat the development cycle solve a problem Programming Logic & Design, Sixth Edition 17 Programming Logic & Design, Sixth Edition 18 3 Writing Pseudocode Writing Pseudocode (continued) • Pseudocode representation of a number-doubling • Programmers preface their pseudocode with a problem beginning statement like start and end it with a start terminating statement like stop input myNumber • Flexible because it is a planning tool set myAnswer = myNumber * 2 output myAnswer stop Programming Logic & Design, Sixth Edition 19 Programming Logic & Design, Sixth Edition 20 Drawing Flowcharts Drawing Flowcharts (continued) • Create a flowchart • Output symbol – Draw geometric shapes that contain the individual – Represents output statements statements – Parallelogram – Connect shapes with arrows • Flowlines • Input symbol – Arrows that connect steps – Indicates input operation • Terminal symbols – Parallelogram – Start/stop symbols • Processing symbol – Shaped like a racetrack – Processing statements such as arithmetic – Also called lozenge – Rectangle Programming Logic & Design, Sixth Edition 21 Programming Logic & Design, Sixth Edition 22 Drawing Flowcharts (continued) Repeating Instructions • After the flowchart or pseudocode has been developed, the programmer only needs to: – Buy a computer – Buy a language compiler – Learn a programming language – Code the program – Attempt to compile it – Fix the syntax errors – Compile it again Figure 1-6 Flowchart and pseudocode of program that doubles a number – Test it with several sets of data – Put it into production Programming Logic & Design, Sixth Edition 23 Programming Logic & Design, Sixth Edition 24 4
no reviews yet
Please Login to review.