0% found this document useful (0 votes)
3 views

Constructs

Uploaded by

Kutsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Constructs

Uploaded by

Kutsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Constructs

Test a value named Total, if it’s less than or equal to 10, add 1 to Total,
otherwise reset the value to 0.

IF Total is less than or equal to 10


Add 1 to Total
ELSE
Reset Total to 0

Test a value named Color. If Value is Red, print STOP, if value is Yellow,
print SLOW, if value is Green, print GO!

IF Color is Red
Print STOP
ELSE IF Color is Yellow
Print SLOW
ELSE IF Color is Green
Print GO

Read in 20 number values. If the value is even, print the value otherwise
skip it.

FOR each number in the list of 20 numbers


IF number is even
Print the number
ELSE
Skip the number

Read in a list of number values (the list can be different sizes at different
times). Add the sum of the values in a variable called Total.

Initialize Total as 0
FOR each number in the list
Add the number to Total

Print each character of a line until you reach a semi-colon.

FOR each character in the line


IF character is a semi-colon
Stop reading the line
ELSE
Print the character

You might also like