Lecture 1 Introduction To Programming
Lecture 1 Introduction To Programming
Lecture 1 Introduction To Programming
COMPUTER
PROGRAMMING
1
Introduction to Programming
Program: The term program refers to a set of instructions
that instructs a computer on what to do. Programs are
Solutions to Problems, and they are written using
programming languages.
•A program can instruct a computer to:
– Read/ accept Input data
– Calculate or compare
– Store data
– Write or display Output and communication messages.
2
ALGORITHM
SEQUENCE OF STEPS TO SOLVE THE PROBLEMS
3
ALGORITHM
SEQUENCE OF STEPS TO SOLVE THE PROBLEMS
4
Advantages of algorithm
5
FLOWCHART
A flowchart is
a graphical
representation
of steps.
6
7
8
Advantages of flowchart:
9
DECISION STRUCTURES
• The structure is as follows
If condition then
true alternative
else
false alternative
endif
10
Example 1: Write an algorithm to determine a student’s final grade and
indicate whether it is passing or failing. The final grade is calculated as the
average of four marks.
11
Example 2 Write an algorithm and draw a flowchart to convert the length
in feet to centimeter.
12
13
PRACTICE QUESTIONS
1. Write an algorithm and draw a flowchart that will read the two sides of a
rectangle and calculate its area.
14