Chapter 4 Notes - Programming and Problem Solving PDF
Document Details
Uploaded by EfficaciousComplex8214
Amrita Vidyalayam
Tags
Related
Summary
These notes cover foundational programming concepts, including problem-solving approaches, programming phases, algorithms, and flowcharts.
Full Transcript
Chapter-4 Principles of Programming and Problem Solving 1. Write short note about approaches in problem solving There are two approaches in problem solving, Top down design Bottom up design Top down design : In top down design method a big program is divided into sub program...
Chapter-4 Principles of Programming and Problem Solving 1. Write short note about approaches in problem solving There are two approaches in problem solving, Top down design Bottom up design Top down design : In top down design method a big program is divided into sub programs and these sub programs(modules) are solved to get the result. It helps us to clarify what is to be done in each part. – Allows more than one person to work for the solution. – Easier to figure out – Parts of the solution may turn out to be reusable. Bottom up design: Once the overall procedure or task is broken down into component parts (modules) and each component module is further sub divided until the lowest level of detail has been reached, we start solving from the lowest module onwards. 2. Explain Phases in programming The different stages in programming are, 1.Problem identification 2.Preparating algorithms and flowcharts. 3.Coding 4.Translation 5.Debugging 6.Execution and testing 7.Documentation 1.Problem identification :In this phase the problem is analysed. The data involved in processing, the output to be obtained are identified. 2. Algorithms and Flowcharts : Once the problem is identified, a step-by-step procedure is developed to solve the problem. Algorithm : An algorithm is a finite sequence of instructions to solve a problem. Flowchart : It is a pictorial representation of an algorithm with specific symbols for instructions and arrows showing the sequence of operations. 3.Coding : The process of writing program instructions to solve a problem is called Coding. We can use human friendly language, known as HLL for Coding. The program written in any HLL is known as source code. Eg. BASIC, FORTRAN, COBOL, C, C++ 4.Translation : It is the process of converting a program written in HLL into its equivalent version in machine language. The compiler, or interpreter is used for this purpose. During this step, the syntax errors of the program will be displayed. 5.Debugging It is the stage where programming errors are discovered and corrected. Programming errors are known as ‘BUGS’ and the process of detecting and correcting these errors is called Debugging. There are two types of errors that occur in a program. SYNTAX, LOGICAL 6.Execution and testing When the compiled version of the program is formed, it should be executed for testing. The purpose of testing is to determine whether the results are correct. The accuracy of the program logic can be determined by this testing. 7.Documentation A computerised system cannot be considered to be complete until it is properly documented. We can write comments in the source code as part of documentation. It is known as INTERNAL DOCUMENTATION. Another version of documentation is the preparation of system manual and user manual. While developing software for various applications, these manuals are mandatory. This kind of documentation is known as EXTERNAL DOCUMENTATION. 3. Characteristics of an algorithm 1) It should begin with instruction(s) to accept inputs. 2) Each instruction must be precise and should have only one meaning. 3) The number of instructions must be finite. 4) An algorithm must produce desired output. 4. Explain Flowchart It is a pictorial representation of an algorithm with specific symbols for instructions and arrows showing the sequence of operations. Symbols used in a flowchart 5. Advantages of flowchart 1)Better communication :Flowchart are the better way of communicating the logic of a program. 2)Effective analysis :Effective analysis of a program can be done using a flowchart. 3)Effective synthesis :Flowchart are used as a working model in designing a new program. 4)Efficient coding :Flowchart guide the programmer in writing the code. 6. Limitations of flowchart 1. It is time consuming and laborious to draw with proper symbols. 2. Any change or modification in the logic of the algorithm usually requires a completely new flowchart. 3. There are no standards determining the amount of detail that should be included in a flowchart. 7. Compare Entry controlled and exit controlled loops Entry Controlled Loop Exit Controlled Loop Condition is checked before the execution Condition is checked after the execution of the body of the body Body of loop may never be executed. Body of loop will surely be executed at least once. Suitable when skipping of the body of the Suitable when normal execution of the loop being executed is required. body of loop is to be ensured. 8. Which flow chart symbol is always used in pair? Connectors 9. Program written in HLL is known as ____________. Source code 10.What is an object code? The code which converted from source code. 11.What is SYNTAX ERROR? When the rules or syntax of the programming language are not followed then there will be program errors. It is called SYNTAX ERROR. Such program errors typically involve incorrect punctuation, incorrect word sequence, undefined term or illegal use of terms or constructs 12. what is Logical error? It is due to improper planning of the program’s logic. The computers do not tell us what is wrong. It should be identified by the programmer or user. ***Algorithms and flowcharts should be copied from text or videos(HW).*****