C Prog Lesson 1

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

Introduction to

Problem Solving
Lesson 1

What is a
COMPUTE
R?

A COMPUTER is a
programmable
machine that receives
input,
stores
and
manipulates data, and
provides output in a
useful format.
(Wikipedia)

COMPUTE
R
Programm
able

Machine

Software

Hardware

Software
is any set of machine-readable
instructions (program) that
directs a computer's processor
to perform specific operations.

Algorithm
a
step-by-step
list
of
instructions for solving any
instance of the problem.

2 Tools in
Representing
Algorithms
Flowchart
Pseudo-code

Flowchart:
Represents an algorithm
in graphical symbols

Pseudo-code
also describes the essential
steps to be taken, but
without the graphical
enhancements.

Flowchart Symbols
Symb
ol

Meaning
The terminator
symbolrepresents the start
points, end points, and
potential outcomes of a path.
The data symbol(also called
the input/output symbol)
represents data that is
available for input or output. It
may also represent resources
used or generated.

Flowchart Symbols
Symb
ol

Meaning
The process
symbolrepresents a process,
action, or function. Its the
most widely-used symbol in
flowcharting.
The decision
symbolindicates a question to
be answeredusually yes/no or
true/false. The flowchart path
may splinter into different

Flowchart Symbols
Symb
ol

Meaning
The connector
symbolconnects separate
elements across one page. Its
usually used within complex
charts.
The preparation
symboldifferentiates between
steps that prepare for work and
steps that actually do work.
The Flow lineused to indicate

Sample Pseudocode:

MAKING A
TEA
Fill kettle with

water
Heat water
IF water boiled then
Make a tea
ELSE
Heat water

Sample
Flowchart:

STAR
T

MAKING A
TEA

Fill kettle
w/ water

Heat water

No

Has the
water
boiled?

-Terminator Symbol

-Data Symbol

-Process Symbol

-Decision Symbol

Yes
Make a tea

End

-Process Symbol

-Terminator Symbol

Create a flowchart for the


following steps in waking - up
Alarm rings
If not ready to get up
Hit snooze button
Sleep again
Else turn off alarm
Climb out of bed

Create a flowchart for the


following steps in going to
school
Leave home
Check time
If before 6:30
Walk to school
Else ride a tricycle
Reach school

Create a flowchart for the


following steps in making a
tea

1. Fill kettle with water


2. Take cup out of cupboard
3. Get tea bag from the cup board
4. Add tea
5. Pour water
6. If require sugar
7. Get a sugar out of the cupboard
8. Add sugar
9. Else do nothing
10.If require milk
11.Take milk out of the fridge

You might also like