Chapter - 11 Program Development Cycle
- Define program development cycle. Mention its steps with a figure.
Answer:
The program development cycle is a set of steps or phases that are used to develop a program in any programming language. - What is problem analysis? Why is it important in programming?
Answer:
The first and very important step of the program development cycle in which the developer should think about the input data, logical processes and required output from the given data.
It is important in programming because until the problem is not clear, the desired solution is not obtained. - Define program designing tools. Mention two most commonly used tools in programming.
Answer:
The tools used to plan the program before writing codes to the computer to avoid errors in computer program is called program designing tools. The most commonly used tools in programming are (i) Algorithm and (ii) Flowchart. - What is documentation? Write its importance.
Answer:
Documentation refers to the written material of a program which include flowchart, algorithm, source code and other manuals of computer program.
It is important because it helps the user to understand the use of program and are also useful for the programmers for the maintenance and redesigning of the program. - Define algorithm.
Answer:
A set of well defined rules for solving a problem in a finite number of steps is called algorithm. - Mention characteristics / properties of a good algorithm.
Answer:
An algorithm should have the following characteristics:
(a) The steps mentioned in an algorithm should be executed by the computer.
(b) It should not have any doubt about the execution of next statement.
(c) The steps of an algorithm should be finite.
(d) It should not depend on a particular computer language.
(e) After a finite number of steps, it should be concluded. - What are the three different structures of a program? Explain them with examples.
Answer:
The three different structures of a program are as follows:
(i) Sequential Structure
(ii) Selection Structure
(iii) Looping Structure(i) Sequential Structure: A sequential execution is a logic that executes statements sequentially that is one after another or from top to bottom.(ii) Selection Structure: A selection structure is a logic that depends upon a condition and makes a choice between two alternative paths. If the condition is true, it follows the path of the true side. Otherwise, it follows the path of false side. The following structure shows a selection structure:(iii) Looping Structure: A loop structure is a logic that is used to execute statements blocks for a number of times without recoding them. A loop structure may have pre-test loop structure or post-test loop structure. The following structure shows the loop structure logics. - Write an algorithm to find the sum and average of three different numbers.
Answer:
Step 1: Start
Step 2: Initialize variables for sum and average to zero. (Sum=0 , Average=0)
Step 3: Read three numbers using variable num1,num2 and num3.
Step 4: Find the sum of three numbers where
sum=num1+num2+num3
Step 5: Find the average of three numbers where
Average= sum / 3
Step 6: Print sum, average.
Step 7: Stop - Write an algorithm to find the greatest among two different numbers.
Answer:
Step 1: Start
Step 2: Read two different numbers using variable num1 and num2.
Step 3: Is num1 greater than num2?
3.1 If Yes: Print " num1 is greater."
3.2 If No: Print "num2 is greater."
Step 4: Stop - Write an algorithm to find the sum of first five even numbers.
Answer:
Step 1: Start
Step 2: Initialize variables sum = 0, i = 1, a = 2
Step 3: Is i<=5?
3.1 If Yes: Print a , sum = sum + a , a = a + 2
and go to step 4.
3.2 If No: go to step 5
Step 4: calculate i=i+1 and go to step 3
Step 5: Print sum
Step 6: Stop - Define flowchart.
Answer:
A diagrammatic representation of the steps involved in solving a problem is called flowchart. - Make a list of symbols commonly used in flowchart with their meanings.
Answer: - Mention some of the rules and guidelines of a flowchart.
Answer:
(i) A flowchart should be neat and clean.
(ii) Use only one start and one stop point.
(iii) Always concentrate on the main logic of the problem.
(iv) Avoid using computer language in a flowchart.
(v) The terms used in the flowchart should be clear, so that another programmer can easily understand the logic.
(v) The direction of flow of the procedure should be from left to right or top to bottom.
(vi) Only one line should come out from a process symbol.
(vii) Only one flow line should enter a decision symbol. However, two flow lines may come out. - Write advantages of a flowchart.
Answer:
(i) Any errors occurring in the logical can be easily detected.
(ii) It is an effective communication tool.
(iii) It is very helpful in case of modification of the program in the future.
(iv) Once the flowchart is complete, it acts as a guideline and makes easy to write the program. - Write disadvantages of flowchart.
Answer:
(i) It is a time consuming task.
(ii) Programs can be modified but it is not possible to modify the flowchart. It should be redrawn, which becomes costly.
(iii) When there are complex branches and loops, the flowchart becomes more complicated. - Logical errors are difficult to find and correct. Express your views.
Answer:Logical errors may occur in the program due to the fault designing, fault analysis, wrong formulae etc. These errors are difficult to find because language translators can not detect logical errors and do not produce any errors messages. The program may run successfully in presence of logical errors, but they produce a wrong result. - Draw flowchart to find the sum and average of three different numbers.
Answer: - Draw flowchart to find the greatest among two different numbers.
Answer: - Draw flowchart to find the sum of five even numbers.
Answer:
Worked Out Examples
- Find the sum and average of any four numbers.
Algorithm to find sum and average of any four numbers.
Step 1: Start
Step 2: Input four numbers as num1,num2,num3 and num4
Step 3: sum=num1+num2+num3+num4 and average=sum/4
Step 4: Print sum and average
Step 5: StopFlowchart to calculate sum and average of four numbers - Calculate the sum, difference and product of any two numbers.
Algorithm to calculate the sum, difference and product of any two numbers
Step 1: Start
Step 2: Input two numbers as num1 and num2
Step 3: sum=num1+num2 , difference=num1-num2 and product=num1*num2
Step 4: Print sum, difference and product
Step 5: Stop - Find the area of a rectangle where A=L*B.
Algorithm to find the area of rectangle where A=L*B
Step 1: Start
Step 2: Input length and breadth as L and B
Step 3: area = L*B
Step 4: Print area
Step 5: StopFlowchart to find area of rectangle where A=L*B - Print the area of four walls where A=2H(L+B).
Algorithm to find the area of four walls where A=2H(L+B)
Step 1: Start
Step 2: Input length , breadth and height as L , B and H
Step 3: area = 2*H*(L+B)
Step 4: Print area
Step 5: StopFlowchart to find the area of four walls where A=2H(L+B) - To input a number and check whether the input number is "Even" or "Odd".
Algorithm to test whether the given number is "Even" or "Odd"
Step 1: Start
Step 2: Input any number as num
Step 3: Find remainder(R) of num divided by 2.
Step 4: Is R equal to zero?
4.1: If true, Print "Even"
4.2: If false, Print "Odd"
Step 5: StopFlowchart to test whether the given number is "Even" or "Odd" - To display the greatest number among three different numbers.
Algorithm to find the greatest number among three different numbers
Step 1: Start
Step 2: Input three different numbers as num1,num2 and num3
Step 3: Is num1>num2 and num1>num3?
3.1: If true, Print "num1 is greatest " and go to step 6
3.2: If false, go to step 4
Step 4: Is num2>num1 and num2>num3?
4.1: If true, Print "num2 is greatest " and go to step 6
4.2: If false, go to step 5
Step 5: Print "num3 is greatest"
Step 6: StopFlowchart to find the greatest number among three different numbers - To calculate the factorial of given number (N!=N*N-1*......*1).
Algorithm to find factorial of given number
Step 1: Start
Step 2: Initialize F=1
Step 3: Enter any number as N
Step 4: Set I=N
Step 5: Is I>=1?
5.1: If true, calculate F=F*I and go to step 6
5.2: If false, go to step 7
Step 6: Calculate I=I-1 and go to step 5
Step 7: Print F
Step 8: StopFlowchart to find factorial of given number - To print first ten even numbers and also find their sum.
Algorithm to print first ten even numbers also find their sum
Step 1: Start
Step 2: Initialize I=1, A=2 , sum=0
Step 3: Is I<=10?
3.1: If true, Print A, Calculate sum=sum + A , A=A+2 and go to step 4
3.2: If false, go to step 5
Step 4: Calculate I=I+1 and go to step 3
Step 5: Print sum
Step 6: StopFlowchart to print first ten even numbers also find their sum - To print all odd numbers from 99 to 1.
Algorithm to print all odd numbers from 99 to 1
Step 1: Start
Step 2: Initialize I=99
Step 3: Is I>=1?
3.1: If true, Print I and go to step 4
3.2: If false, go to step 5
Step 4: Calculate I=I-2 and go to step 3
Step 5: StopFlowchart to print all odd numbers from 99 to 1 - To test whether the given number is "Prime" or "Composite".
Algorithm to test whether the given number is "Prime" or "Composite"
Step 1: Start
Step 2: Initialize I=1, count=0
Step 3: Input any number as N
Step 4: Is I<=N?
4.1: If true, Calculate remainder(R) of num divided by I and check IS R=0? . If yes, calculate count=count+1 and go to step 5
4.2: If false, go to step 6
Step 5: Calculate I=I+1 and go to step 4
Step 6: Is count equal to two.
6.1: If true, Print "Prime"
6.2: If false, Print "Composite"
Step 7: StopFlowchart to check prime or composite number