programming continues...
When you are given a question to code you don't even start to code because it is not good approach for the programmer to do that. A problem should have input, process and output.
Input is where you put user input, e.g if you are calculating Area of a triangle then user input will be height and width.
process is where you put a formula for calculating that area of triangle. e.g Area = 1/2 x height x width.
finally, there is output... where it will display Area of that triangle.
so, in order for you to code anything you need to specify those three things first.
okay... there are two things which are algorithm and flow charts. These things are not so much far from three things i mentioned about. but here there are little things which will be added.
A typical programming task can be divided into phases
>problem solving phase
produce an ordered sequence of steps that describe solution of problem. This sequence of steps is called Algorithm.
>Implementation phase
Implement the program in some programming language
steps in problem solving
>First produce a general algorithm(one can use pseudocode)>Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.
>Pseudocode is an artificial and informal language that helps programmers develop algorithms pseudocode is very similar to everyday English.
Example of Pseudocode & algorithm
write an algorithm to determine a student's final grade and indicate whether it is passing or falling. The final grade is calculated as the average of four marks.
solution
pseudocode
>input a set of 4 marks
>calculate their average by summing and dividing by 4
>if average is below 50
print 'FAIL'
else
print 'PASS'
detailed algorithm
step 1 input M1, M2, M3, M4
step 2 GRADE<- (M1 + M2 + M3 + M4)/4 step 3 if(GRADE < 50) then print 'FAIL' else print 'PASS' endif
THE FLOWCHART
This is the graphical representation od the sequence of operations in an information system or program. Program flowcharts show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowcharts.Advantage of flow chart
> shows logic of an algorithm
> emphasizes individual steps and their interconnections
>e.g control flow from one action to the next
Flowchart Symbols
i am going to find for you more materials of flowcharts. i hope you will enjoy a lot.
to be continues........
No comments:
Post a Comment