You are on page 1of 6

COMPUTER PROGRAMMING 1

An algorithm is “a finite set of precise instructions for performing a computation or for solving a problem”
A program is one type of algorithm
Directions to somebody’s house is an algorithm
A recipe for cooking a cake is an algorithm
The steps to compute the cosine of 90° is an algorithm

Algorithms generally share a set of properties:


Input: what the algorithm takes in as input
Output: what the algorithm produces as output
Definiteness: the steps are defined precisely
Correctness: should produce the correct output
Finiteness: the steps required should be finite
Effectiveness: solves the problem.
Efficiency: in less time, the result is obtained
Generality: the algorithm should be applicable to all problems of a similar form

Flowchart - Graphically depicts the logical steps to carry out a task and shows how the steps relate to each
other.
Pseudo code - Uses English-like phrases with some Visual Basic terms to outline the program.
What is a flowchart?
A flowchart is a picture (graphical representation) of the problem solving process.
A flowchart gives a step-by-step procedure for solution of a problem.
Elements of a flowchart:
Various geometrical shaped boxes represent the steps of the solution.
The boxes are connected by directional arrows to show the flow of the solution.
Uses of a flowchart:
To specify the method of solving a problem.
To plan the sequence of a computer program.
Communicate ideas, solutions.
COMPUTER PROGRAMMING 1
COMPUTER PROGRAMMING 1
COMPUTER PROGRAMMING 1

Divide-and-conquer method
Used in problem solving – take a large problem and break it into smaller problems solving the small ones first
Breaks a problem down into modules
Statement structures
Sequence – follow instructions from one line to the next without skipping over any lines
Decision - if the answer to a question is “Yes” then one group of instructions is executed. If the answer is “No,”
then another is executed
Looping – a series of instructions are executed over and over

Name: _______________________ Year/Section:___________ Date: _____________


COMPUTER PROGRAMMING 1
I. Complete the crossword puzzle.

1P R C E S S Across
O
1. I am a rectangle in a flowchart. What do I
represent?
2D I A M O N D 2. When you want to show a decision making step,
3 you can use this box.
4. You can use me to communicate ideas, graphically
represent a problem solving process.
5. I connect two geometrical boxes in a flowchart.
Down
4F L O W C H A R T 1. In the flowchart, I represent data or information
that is available.
3. All flowcharts begin with me. I am elliptical in
5A R R O W shape.

II. Match the elements of a flowchart and their purpose of use in the following. Write the letter only.
Purpose Use
_____1. Calculate total of A, B, C A. Loop
_____2. Indicate that the problem has been solved. B. Start
_____3. Find if a number is greater than the other C. Process
_____4. calculate the factorial of the number. D. Input
_____5. Read three numbers E. End
_____6. Print the total F. Decision
_____7. Indicate beginning of a problem solving flow. G. Output

III1. The following flowchart gives the steps followed while


taking attendance in a class. Three arrows and a loop are
missing. Complete the flowchart as follows:
a. Draw the three missing arrows and loop at the correct
place.
b. Label the decision arrows with yes or no.

III.2. A, B, C are the marks scored by a student in Science,


Mathematics and English. Refer the flowchart and answer
the questions.
COMPUTER PROGRAMMING 1
No,
Award a star,
Do better to get a star,
Is average greater than 75

c. Is Sweta awarded a star? Yes or No?


Ans: ___________________
d. Marks of two more students are given below.
Study it and fill in the blanks with the average
marks of each student and whether the
student is awarded or not awarded a star.
Science Math English
Riya 75 80 72
i.Riya’s average is
Suma 72 70 82
n
______ .
So she is ____________a star.
ii. Suman’s average is _____ .
So she is ____________a star.

a. In mathematics and 75 marks in English.


Use the adjacent flowchart and provide the
execution steps in calculating the average
marks of Sweta. The first step is given.
60, 70,75__________

b. A student whose average marks is above 75 is


awarded a star. Fill in the following phrases in
the flowchart on the left for finding if a
student gets a star or not.
Yes,

You might also like