This action might not be possible to undo. Are you sure you want to continue?

3/24/2012

1

Purpose of Program Planning A programmer cannot write the instructions to be followed by a computer unless the programmer knows how to solve the problem manually. 3/24/2012 2 . To ensure that the program instructions are appropriate for the problem and in the correct sequence.

It is a step by step description of how to arrive at the solution of the given problem. It may be formally defined as a sequence of instructions. 3/24/2012 3 .Algorithm The term algorithm is often used to refer to the logic of a program.

Characteristics of Algorithm A sequence of instructions must process the following characteristics: Each and every instruction should be precise and unambiguous. that is after the algorithm terminates. One or more instructions should not be repeated infinitely. 3/24/2012 4 . the desired results must be obtained. This ensure that the algorithm will ultimately terminate. After performing the instructions. Each instructions should be such that it can be performed in a finite time.

Programmers normally use one or more of the following ways to represent their algorithms: • As programs • As flowcharts • As pseudocodes 3/24/2012 5 .Representation Of Algorithms There are various ways in which an algorithm can be represented.

Third or Fail) obtained by the student.Sample Algorithms Example 1: 50 students in a class appeared in their final examination. 3/24/2012 6 . Their mark sheets have been given to you. The division column of the mark sheet contains the division (First. Write an algorithm to calculate and print the total number of students who passed in First division. Second.

Sample Algorithms Solution of Example-1: Step 1: Initialize Total_First_Division and Total_Marksheets_Checked to zero. 3/24/2012 7 . go to Step 5. Step 3: Check the division column of the mark sheet to see if it is FIRST. Step 2: Take the mark sheet of the next student. If no.

go to Step 2. Step 7: Print Total_First_Division. Step 5: Add 1 to Total_Marksheets_Checked.Sample Algorithms Step 4: Add 1 to Total_First_Division. Step 8: Stop. Step 6: Is Total_Marksheets_Checked=50? It no. 3/24/2012 8 .

‘B’ for good and ‘C’ for average performance. Every employee’s appraisal form contains his basic salary and the grade for his/her performance during the year. The performance of the employees is recorded in their annual appraisal forms. 3/24/2012 9 . The organization wants to distribute annual bonus to the employees based on their performance. The grade is of three categories – ‘A’ for outstanding.Sample Algorithms Example 2: There are 100 employees in an organization.

3/24/2012 10 . 70% of the basic salary for good performance. Write an algorithm to calculate and print the total bonus amount to be distributed by the organization. 40% of the basic salary for average performance and zero for all other cases.Sample Algorithms Example 2 (Continued): It has been decided that the bonus of an employee will be 100% of the basic salary for outstanding performance.

Step 3: Take the appraisal form of next employee. 3/24/2012 11 . Step 2: Initialize Bonus and Basic_Salary to zero.Sample Algorithms Solution of Example-2: Step 1: Initialize Total_Bonus and Total_Employees_Checked to zero.

7 Go to Step 8. then Bonus = Basic_Salary. then Bonus = Basic_Salary x 0. Step 6: If Grade = B. Goto Step 8. 3/24/2012 12 .Sample Algorithms Step 4: Read the employee’s Basic_Salary and Grade. Step 5: If Grade = A.

3/24/2012 13 . then Bonus = Basic_Salary x 0. Step 9: Add 1 to the Total_Employees_Checked.4 Step 8: Add Bonus to Total_Bonus.Sample Algorithms Step 7: If Grade = C.

Step 12: Stop. 3/24/2012 14 . then go to Step 2. Step 11: Print Total_Bonus.Sample Algorithms Step 10: If Total_Employees_Checked < 100.

Sample Algorithms Example-3 for Practice: A student appears in an examination which consists of total 10 subjects. The roll number of the student. his/her name and the marks obtained by him/her in various subjects are supplied as input data. Write an algorithm to calculate the average marks obtained by the student in this examination and to print it along with his/her roll number and name. 3/24/2012 15 .

write an algorithm to do this task.Sample Algorithms Example-4 for Practice: For the examination of the previous example we want to make a list of only those students who have passed (obtained 30% or more marks) in the examination. If the input data of all students is terminated by a trailer record which has sentinel value of 999999 for Roll no. In the end we also want to print out the total number of students who have passed. 3/24/2012 16 .

Sign up to vote on this title

UsefulNot useful- 1.5-1.9
- EE 212 Old Exams
- Mechanics Oop
- Mental Math Computation Grade 6- Dept. of Education Nova Scotia
- Math Solver
- Interpreting Standard Deviation
- Or 2marks Ans
- MathTasks- Grade2
- Null Sequence
- Assignment 1213
- Output Spss
- cdscv
- i
- Bj4 Lab Ch13 Lab 06
- Salassi - A Primer on Using PROC LP
- AI_SSAote
- Math230 Pe Feb2010 Final (2)
- Mathcad for RC
- Upsc Cds Syllabus
- Θέματα Ρωσικων μαθηματικών διαγωνισμών
- rtqgr6math
- aim docs
- LEC_01
- 240 Syllabus
- Structured Curriculum
- LU Dec Sparse
- en-2001-ioi-vzo
- What is Normal Lesson Plan
- Transformation Multi Choice LP
- Algorithm

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd