Fproglec / Fproglab Reviewer (Prelims)
Fproglec / Fproglab Reviewer (Prelims)
ALGORITHM AND FLOWCHARTING 3. Print out the radius and its PROGRAM THAT CALCULATES THE SUM OF TWO
INPUT NUMBERS
A typical programming task can be
Example 3:
divided into two phases: Write an algorithm to determine a student’s final grade
1. Problem solving phase
and indicate whether it is passing or failing. The final
• produce an ordered sequence of steps that describe grade is calculated as the average of four marks.
solution of problem(algorithm)
Step 1: Input M1, M2, M3, M4
•Algorithm is a list of instructions for carrying out some Step 2: GRADE (M1+M2+M3+M4)/4
process step by step
Step 3: if (GRADE < 50)
2. Implementation phase then Print “FAIL”
• implement the program in some programming
else
Print “PASS”
STEPS IN PROBLEM SOVING
Endif
1. First produce a general algorithm (one can use FLOWCHART IF-THEN STRUCTURE
pseudo code) FLOWCHART
• Pseudo code is an artificial and informal language (Dictionary) A schematic representation of a sequence
that helps programmers develop algorithms. Pseudo of operations, as in a manufacturing process or
code is very similar to everyday English. computer program.
2. Refine the algorithm successively to get step by (Technical) A graphical representation of the sequence
step detailed algorithm that is very close to a of operations in an information system or program.
computer language. (Technical) a diagram representing the logical
sequence in which a combination of steps or
PSEUDOCODE & ALGORITHM operations are to be performed.
Example 1:
Program that calculates the sum of two input
FLOWCHART
numbers shows logic of an algorithm
1. Enter two numbers
emphasizes individual steps and them
(n1, n2) interconnections
2. Compute the sum (sum =
e.g., control flow from one action to the next
n1 + n2)
3. Display the sum
FLOWCHART BASIC SYMBOLS
Example 2:
Program to compute the area of a circle.
Radius is equal to 1 unit. Display the radius
and its area
1. Define the value of the
radius (r) and PI (3.1416)
2. Calculate the area of the
circle (A = PI*r*r)
FPROGLEC / FPROGLAB REVIEWER (PRELIMS)
BRIEF HISTORY OF C LANGUAGE
1960’s -Dennis Ritchie was working at AT&T Bell Labs
to develop an operating system.
INTRODUCTION TO C LANGUAGE