Escolar Documentos
Profissional Documentos
Cultura Documentos
to
Programming
REPETITION
while
loops
Control
of
Flow
SEQUENCE
SELECTION
-
if,
if
else
REPETITION
while,
do
while,
for
Repe))on
Repe))on
also
known
as
itera)on,
and
as
Looping
Some)mes
when
wri)ng
a
program
we
want
to
repeat
an
ac)on
several
)mes:
Input
several
numbers
Add
up
a
list
of
numbers
Output
several
messages
C
program
#include
<stdio.h>
void
main()
{int
age
=
10;
while
(age
<
18)
{
prinO(You
cant
drive);
prinO
(You
are
aged
,
%d
&age);
age++;
}
prinO(You
are
18
now
so
you
can
drive);
}
#include <stdio.h> void main() { int input; Int PIN = 1234; Int yes =1; while(yes == 1) { prin>(please enter your PIN number); scanf(%d, &input); if (input == PIN) { prin>( Your PIN number was correct, you can access your bank account); } else { prin>(Your PIN number was INCORRECT, you cannot access your account); } prin>(Enter 1 to try again, and 0 to exit); scanf(%d, &yes); } }
#include <stdio.h> void main() { int input; Int PIN = 1234; Int yes =1; while(yes == 1) { prin>(please enter your PIN number); scanf(%d, &input); if (input == PIN) { prin>( Your PIN number was correct, you can access your bank account); yes = 0; } else { prin>(Your PIN number was INCORRECT, you cannot access your account); prin>(Enter 1 to try again, and 0 to exit); scanf(%d, &yes); } }