Page 1 :
Unit I: Computational Thinking and Programming - 1, , Chapter-6 Introduction to Problem solving, , Learning to write computer program is very much like learning any, skill. First, we should understand the problems well and then try to, solve it in a logical manner. Computer programming is the process, of writing, testing, troubleshooting, debugging and maintaining of a, computer program., , Introduction to Problem Solving, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 2 Problem Analysis, , 3 Algorithms, , 4 Flowchart: Visual Representation of Algorithms, , 5 Pseudocode, , 6 Example 1: Write an algorithm to find area of a rectangle, , 7 Example 2: Write an algorithm and draw the flowchart for finding the average, of two numbers, , 8 Example 3: To check greatest of two numbers, , 9 Example 4: Write an algorithm (pseudocode) and draw a flowchart to, calculate 2°., , 10 Example 5: Let us write an algorithm (pseudocode) to check whether a, number is odd or even., , 11 Example 6: Write pseudocode and draw flowchart to accept numbers till the, user enters 0 and then find their average., , 12 Coding, , 13 Testing and Debugging, , 14 Documentation, , , , , , , , , , Page lof 16
Page 2 :
Unit I: Computational Thinking and Programming - 1, , Chapter-6 Introduction to Problem solving, , > Problem solving is a process of transforming the description of a, problem into the solution of that problem by using our knowledge of, the problem domain and by relying on our ability to select, and use appropriate problem-solving Strategies, Techniques and, Tools., , > Problem solving (within the context of developing programs) refers, to analyzing a problem with the intention of deriving a solution for, the problem., , Steps for Problem Solving:, , = Requirements specifications, , = Problem analysis., , = Design the algorithm to solve, the problem., , = Implementation., , = Testing and verification., , = Documentation., , , , Page 2 of 16
Page 3 :
Unit I: Computational Thinking and Programming - 1, , Chapter-6 Introduction to Problem solving, , - State the problem clearly and unambiguously (Doubtless) to understand, exactly:, , = What the problem is?, , = What is needed to solve it?, , = What the solution should provide, , = If there are constraints and special conditions., , It is important to clearly understand a problem before we begin to find, the solution for it. In the analysis phase, we should identity the following:, , = Inputs: To the problem, their form and the input media to be, used., , = Outputs: Expected from the problem, their form and the output, media to be used., , = Special constraints or (necessity) conditions (if any), , = Formulas or equations to be used. Example:, , Problem: Compute and display the total cost of apples given the number, of kilograms (kg) of apples purchased and the cost per kg of apples., , = Input: Quantity of Apples purchased (in kg)., = Cost per kg of Apples (in Rs. per kg)., , = Output: Total cost of Apples (in Rs.)., , = Constraint: N/A, , = Formula: Total cost = Cost per kg x Quantity., Page 3 of 16
Page 4 :
Unit I: Computational Thinking and Programming - 1, , Chapter-6 Introduction to Problem solving, , An algorithm is a precise specification of a sequence of instructions, to be carried out in order to solve a given problem., , An Algorithm is a technique to solve a given problem systematically., An Algorithm is a step-by-step approach to solve a given problem in, finite number of steps., , It takes a set of input values and processes it and gives the output., , Each instruction tells what task is to be performed., , It should be simple., , It may accept zero or more inputs., , It should be precise with no ambiguity., It should have finite number of steps., , It should produce at least one output., , The way of execution of the program shall be categorized into three, , ways:, , (i) Sequence statements;, (ii) Selection statements; and, (iii) Iteration or looping statements. This is also called as “control, , structure”., , Page 4 of 16
Page 5 :
Unit I: Computational Thinking and Programming - 1, , Chapter-6 Introduction to Problem solving, , Sequence! statements: Steps that execute, , in sequence are represented by symbols, , that follow each other top to bottom or, , ere =, , Top to bottom is the standard., , , , Selectivel/Statements: In this program,, , , , , , , , , , , , No, some portion of the program is executed, based upon the conditional test. If the Y, conditional test is true, compiler will | Precess 1, execute some part of the program,, Process 2, , otherwise it will execute the other part, , , , , , , , of the program., , iterativelstatements: In some programs,, , certain set of statements are executed, , again and again based upon conditional, , , , test. i.e. executed more than one time., , , , , , , , , , This type of execution is called “looping, , , , or iteration”., , Page 5 of 16