Beruflich Dokumente
Kultur Dokumente
the division column of their marksheet contains the division(First,Second,Third or Fail) obtained by them.If their marksheet re available with you,Write an algorithm to calculate and print the total no of students who passed in 1st division.
Representation of Algorithms
Tools used to document and represent program logic are: Programs Flowcharts Pseudocodes.
Flowchart
Pictorial representation of algorithm A program planning tool for visually organising sequence of steps Boxes of different shapes denote different types of instructions Instructions are written within the boxes Solid lines with arrow marks connect these boxes to indicate the flow of operation
Details
TerminatorIndicates beginning , end , pause in programs logic flow Input/output---- Instructions to I/O data from any type of I/O devices Process--- Represents arithmetic and data movement instructions Decision----A point at which a branch to one of 2 or more alternative points is possible
Contd
Connectors---A pair of identically labeled connector symbol indicate continued flow Flow Lines---Indicate flow of operation i.e sequence in which instructions are executed
Advantages
Proper Program Documentation Efficient Coding Systematic Testing and Debugging
limitations
Time consuming Modifications require completely new flowchart No standards to determine the details to be included
Example
flowchart for a program that reads two numbers and displays the numbers read in decreasing order
Example
Pseudo Code
Phrases written in ordinary natural language that computer cant understand Also known as Program Design Language It does not have any syntax rules for formulating instrctions
Sequence Logic
Performing instructions one after the other in sequence
Contd
Flowchart Pseudo code Read NAME, BALANCE, RATE Compute INTEREST as BALANCE x RATE Write (Display) NAME and INTEREST
Selection/Decision Logic
To select proper path out of 2 or more alternative paths in program logic
Iteration Logic
When 1 or more instructions may be executed several times depending on some condition
Types of loops
Contd
Most programs involve repeating a series of instructions over and over until some event occurs. For example, if we wish to read ten numbers and compute the average, we need a loop to count the number of numbers we have read. Count loops are loops where the program must count the number of times operations are completed.