1 / 13

Introduction to Computer Programming

Introduction to Computer Programming. Program Design. By: Mr. Baha Hanene. Learning Outcomes. In this chapter we will cover L01 completely & L03. Discuss the features of a high-level language. (L01) Interpret pseudo code and describe its function. (L03). Contents. Program Design.

sherri
Télécharger la présentation

Introduction to Computer Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computer Programming Program Design By: Mr. BahaHanene

  2. Learning Outcomes • In this chapter we will cover L01 completely & L03. • Discuss the features of a high-level language. (L01) • Interpret pseudo code and describe its function. (L03)

  3. Contents

  4. Program Design Definition: Employment of an algorithmic approach for the development of a solution to a problem, producing tested programs to meet given specifications PDL Program Design Language: A language, used for expressing program designs , that is similar to a conventional high-level programming language but emphasizes structure and intention rather than the ability to execute programs expressed in the language

  5. Developing an Algorithm Defining a Problem: The problem should be divided into three different components. • Input (A list of source data provided to the problem) • Processing (A list of actions to be performed) • Output ( The final outcome of the whole process) Naming a Variables: Be careful in using the name of variable it should have the following characteristics • Self Explanatory • Easy to Understand e.g. For Storing Dirhams the variable name could be Currency.

  6. Solution Algorithm Designing a Solution Algorithm: This is the most challenging part of the program once you design a solid algorithm the rest problem remains nothing below are details • Make a general sketch of the system • Identify the control structures • Try to have an understanding that how procession will take place • Do not hesitate to alter or discard the algorithm • Do not start coding in hurry Check the Solution Algorithm: After a solution algorithm is constructed it must be tested for correctness, as most logical errors occur during development.

  7. Solution Algorithm Desk Checking the Algorithm: It involves tracing through the logic of the algorithm with some chosen test data. Selecting Test Data: Choose simple test cases only, based on the requirements of the specification, not the algorithm. Steps in Desk Checking an Algorithm There are six simple steps to follow in desk checking of an algorithm • Choose simple input test cases which are valid. • Establish what the expected results should be for each test case. • Make a table of relevant variable names on a paper. • Walk the first test case through the algorithm (Dry Run). • Repeat the walk-through process using other test cases. • Check that the expected results established in step 2 matches the actual result developed in step 5.

  8. Pseudo Code How to write a pseudo code…? Each operation of a computer can be represented as a straight forward English instruction, with keywords and indentation to signify a particular control structure. Six Basic Computer Operations: • A computer can receive information • A computer can put out information • A computer can perform arithmetic • A computer can assign a value to a piece of data • A computer can do comparison and then decision • A computer can repeat a group of actions

  9. Pseudo Code A computer can receive information: Typical pseudo-code instructions to receive information are: • Read student name • Get date • Read number_1, number_2 • Get tax_code A computer can put out information: Typical pseudo-code instructions to put out information are: • Print “Program Completed” • Write customer record to master file • Put out name, address and postcode • Output total_tax • Display end_of_data

  10. Structure Theorem The Structure Theorem? There are basically three control structures according to the structure theorem. The structure theorem states that “It is possible to write any computer program by using only three basic control structures that are easily represented in pseudo-code : Sequence Selection repetition. 1. Sequence Control Structure: It is the straight forward execution of one processing step after another, for example: statement a statement b statement c A typical sequence of statements in an algorithm: • Add 1 to page_count • Print heading line • Set line_count to zero • Read customer record

  11. Structure Theorem 2. Selection Control Structure: It is the presentation of a condition and the choice between two actions, the choice depending on whether the condition is true or false. In pseudo- code the selection is represented by the Keyword IF, THEN and ELSE, for Example IF condition p is true THEN statement (s) in true case ELSE statement (s) in false case Null ELSE Structure: A task is performed only if a particular condition is true. The null ELSE Construct is written in pseudo-code as: IF condition p is true THEN statement (s) in true case

  12. Structure Theorem 3. Repetition Control Structure: It can be defined as the presentation of a set of instructions to be performed repeatedly, as long as a condition is true. It means that “A block of statements is executed again and again, until a terminating condition occurs”. It is written in pseudo-code as: WHILE condition p is true { statement block } Example: Set student_total to zero WHILE student_total < 50 { Read student record Print student name and address Add 1 to student_total }

  13. Conclusion • We can define what is an algorithm…? • How to write and to deal with it …? • What is a pseudo code …? • What is a desk check …? • What is structure theorem …? • What is Sequence Control …? • What is Selection Control …? • What is Repetition Control …?

More Related