|
||||||||
![]() |
||||||||
|
|
||||||||
|
|
0
Programming
Programming is required to solve a specific problem. It is a set of instructions written in a particular language, to solve a particular problem. There are some steps needed to write a program: 1) Define the problem eg To find out the average of three numbers 2) Determine input & output variables: > Input variables 1. First Number 2. Second Number 3. Third Number (Spaces are not allowed in variable names) >Output Variable * Average 3) Create some cases Variable Case1 Case2 Case3 First number 4 4.94 0 Second Number 9 6.03 0 Third Number 5 10.59 0 Average 6 0 4) Write high-level algorithm > Algorithm: is the step by step procedure to solve the problem Steps: A. Take three inputs/ Assign three inputs to the three variables B. Calculate the average of 3 numbers C. Display the output/ value of the average 5) Refine the algorithm 4b. * Total three numbers * Divide the total by 3 6) Develop flowchart *Flowchart: It is the graphical representation of the steps to solve the problem *Functions: 1) Are easier to understand at a glance than a narrative description 2) Assist in reviewing and debugging of a program 3) Provide effective program documentation and 4) Help in the discussion of a solution with others or in explaining the program to others *Symbols used in FC: 1) Oval: Start or end. 2) Parallelogram: Input & Output 3) Rectangle: Process/Arithmetic operations 4) Diamond: Decision Making 5) Arrow: Flow direction 6) Circle: Continuation of the FC Example: (use symbols) start>input three numbers>calculate the average>output the average> Stop 7) Write the program INPUT: First Number = 1 Second Number = 9 Third Number = 5 Processing: Total = First Number + Second Number + Third Number Average = Total/3 Output: Print Average 8) Test the program > Execute the program: If the program does not provide the expected output the program requires debugging. Operators: 1.Mathematical (-,+,*,/,") 2. Relational (>,<,=)
|
|
||||||
|
© WP Technology Inc. 2009
User-posted content is subject to its own terms. |