Introduction To Programming 1
Introduction To Programming 1
to Programming
Programming
Processing
-
ALOGORITHM
ALGORITHM
Series
of
step
by
step
instruc9ons
that
solve
a
problem
Make
a
cup
of
coee
Find
the
exit
of
a
building
Calculate
a
persons
wages
ALGORITHM
to
code
INPUT
int
rate;
int
hours;
int
salary
prinQ(Input
hourly
rate);
scanf(
%d
,nrate
)
;
print(
input
hours
worked);
scanf(
%d
,nhours
)
;
ALGORITHM
to
code
PROCESSING
salary
=
rate
*
hours;
ALGORITHM
to
code
OUTPUT
prinQ(Salary
is
%d,
salary
);
#include
<stdio.h>
main()
{
int
rate;
int
hours;
int
salary;
prinQ(Input
hourly
rate);
scanf(
%d
,nrate
)
;
print(
input
hours
worked);
scanf(
%d
,nhours
)
;
salary
=
rate
*
hours;
prinQ(Salary
is
%d,
salary
);
C CODE
Control
of
Flow
The
order
in
which
programming
statements
are
executed.
SEQUENCE
SELECTION
REPETITION
SEQUENCE
SEQUENCE
programming
statements
are
executed
one
a`er
another,
in
the
order
they
appear.
Star)ng
at
the
top
and
going
down.
INPUT
Hourly
Wage
Rate
and
Hours
Worked
PROCESSING
Salary
=
Rate
*
Hours
OUTPUT
Salary
SELECTION
Some)mes
whether
an
ac)on
is
carried
out
depends
upon
a
condi)on
being
true
or
false
At
what
age
can
you
drive
a
car?
IF
your
age
is
greater
than
17
THEN
you
can
drive
IF
age
>
17
THEN
you
can
drive
SELECTION
in
C
If
(something
is
true)
{
//do
something
}
If
(3
>
2)
{
prinQ(3
is
greater
than
2);
}
IF
ELSE
IF
(something
is
true)
THEN
{do
this}
ELSE
{when
false
do
that}
if
else
in
c
if
(condi)on)
{
statements}
else
{
statements}
if
else
int
i;
scanf(%d,
i);
if
(i
>
o)
{
prinQ(the
number
was
posi)ve);
}
else
{
prinQ(the
number
was
nega)ve
or
zero);
}