Week 1 - Introduction To Programming

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

ICT002

COMPUTER
PROGRAMMING 1
Topic 1
introduction to
programming
3
What is
programming?
4
Programming Concept

 Computers are not actually smart. It cannot make


decisions or do operations by itself.
 It needs programs for it to know what task
should it perform and how it should be done
 Programming – is the process of developing and
implementing various sets of instructions to
enable a computer to do a certain task.

5
Programming Concept

6
WHAT IS THE MAIN PURPOSE
OF PROGRAMMING?
.
- the main objective of programming is to solve a problem.

7
Programming Programming and its purpose

 Humans cannot solve a lot of problems in just a matter of seconds... but a computer can.
 It has long been known that computers can improve our daily lives. From calculating large
amounts of data, from storing and retrieving information in a secure place, and in
communicating with our loved ones in a faraway place.
 But all of that capabilities, a computer cannot do by itself. A computer is just a tool that can
be used to implement a plan for solving a problem.
 It needed the help and guidance of a computer program.

8
Programming Programming and its purpose

 Computer program – is a set of instructions for a computer. These instructions describe the
steps that the computer must follow to implement a plan.
 A detailed plan for solving a problem is called an algorithm. It is a process or set of rules to
be followed in calculations or other problem-solving operations, especially by a computer.

9
Programming Algorithm vs Computer Program
Problem Statement:
Write a solution on how to find the average grades of a class of 10 students.
Algorithm Computer Program

1. Identify the grades of the 10


students.
2. Add all the grades.
3. Divide the total of the grades by 10.
4. Round off the answer by two
decimal places.
5. Show the result.

10
Programming Algorithm Development Process

Algorithm Development Process


– this is a key step in solving a problem. It consists of five major
steps:
1. Obtain a description of the problem.
2. Analyze the problem.
3. Develop a high-level algorithm.
4. Refine the algorithm by adding more detail.
5. Review the algorithm.
11
Programming Algorithm Development Process

 The figure below represents the “Pick and Plant” problem. One must apply the
algorithm development process to fully understand the concept.

12
Programming Algorithm Development Process
A problem statement is a short, clear
 Step 1: Problem Statement explanation of the issue
– A kangaroo starts at (0, 0) facing East with no flowers in its pouch. There is a flower at location (0, 3).
– Write an algorithm that directs the kangaroo to pick the flower and plant it at location (2, 3).
– After planting the flower, the kangaroo should hop one space East and stop.

13
Programming Algorithm Development Process

A Problem Analysis investigates a situation/problem in order


Step 2: Problem Analysis to allow the programmer to understand more fully the problem

1. The flower is exactly three spaces ahead of the kangaroo.


2. The flower is to be planted exactly two spaces South of its current location.
3. The kangaroo is to finish facing East one space East of the planted flower.

14
Programming Algorithm Development Process

 Step 3: High-level Algorithm


- this step shows the major steps that need to be followed to solve a
problem.
Lets name the kangaroo Bobby. Bobby should do the ff:
1. Get the flower.
2. Put the flower.
3. Hop East.

15
Programming Algorithm Development Process

 Step 4: Detailed Algorithm


Let’s name the kangaroo Bobby. Bobby should do the ff:
1. Get the flower.

1. Hop three times.


2. Pick the flower.
2. Put the flower.

1. Turn right and hop two times.


2. Plant a flower.
3. Hop East.

1. Turn left and hop once.

16
Programming Algorithm Development Process

 Step 5: Review the Algorithm


1. The high-level algorithm partitioned the problem into three rather easy subproblems.
2. This algorithm solves a very specific problem because the kangaroo and the flower are in
very specific locations.
3. This algorithm is actually a solution to a slightly more general problem in which the
kangaroo starts anywhere, and the flower is 3 spaces directly ahead of the kangaroo.

17
Programming Input, Process, Output

PROCESS

INPUT OUTPUT

2, 3 Addition 5
18

You might also like