Sie sind auf Seite 1von 2

Example 1.

1: To find the average marks scored in a computer science test in a class In the first stage of problem solving it is necessary for us to be more precise about the structure of the input data. We may want to know whether the marks scored is real or integer type. Next we must also decide what marks have to input, if the student is absent for the test. No of students appearing for the test is not precisely defined. What sort of output is required whether it should be real or integer. Therefore we correct the problem statement by indicating that the output should be in the form of integer. Example 1.2 : To find whether the given number is odd or even. Initially we are confronted with the problem of understanding what is meant by odd or even. Number which can be expressed as multiples of two is an even number. The number which cannot be expressed as multiples of two is an odd number. The problem statement can be modified to represent the following steps 1. 2. 3. 1.3 Start with a number m . Divide the number m by 2. If the number m is completely divisible by 2 then it is number m is even, otherwise it is odd. PROBLEM ANALYSIS

In problem analysis we try to understand the requirements of the problem to be solved. This process is the first step towards the solution domain. Explicit requirements about the input output, time constraints, processing requirements, accuracy, memory limitations, error handling and interfaces are understood at this stage. The end result of this analysis is the selection of a method, which is to be used on the computer or a decision that a computer should not be used because of constraints as it may be seen that manual methods are better. To completely and properly specify the input to a program we may have to answer certain questions such as: 1. 2. 3. 4. 5. 6. What What What What What What are the values, which should be provided to the program? is the order in which the input is to be provided? is the format of certain types of data (such as date)? is the accuracy of the input data? is the input device? is the range of values allowed for a particular input?

Similarly to provide the output of a program we may have to answer certain question such as: 1. 2. 3. 4. What are the outputs generated by the program? (The outputs should be clearly and unambiguously specified). What is the format of the outputs? (Which includes type, accuracy and the units) What is the output device? How the outputs should be displayed? (Which includes spacing, layout and heading)

Example 1.3 : Average of marks scored in a computer science test in a class In the analysis of the problem, we have to decide how many students are there in a class. Also we must see what is the maximum marks and minimum marks. That

is nothing but range of values that test marks can take. After finding the average we have to display the average with proper heading. We have to decide the format of the average marks as integer or real. If real then what is the number of decimal places. Example 1.4 : Finding the number odd or even The analysis say that the above problem is applicable only for integer number. Here we have to decide the range of numbers for which the solution is obtained. Steps of solving this problem have been clearly understood in the previous stage. In this stage we understand that the basic operations required in solving the problem includes division and remainder extraction. The method described could be easily applied to any integer. The answer generated after the operation is to be displayed with appropriate heading and layout so that it is clearly understood.

Das könnte Ihnen auch gefallen