Pseudocode Practice
Pseudocode Practice
END IF
Pseudocode to find if number is positive or negative:
INPUT num1
IF num1 > 0
ELSE
END IF
Pseudocode to identify type of triangle based on side:
OUTPUT "Write down the length of the first side of the triangle: "
INPUT length1
OUTPUT "Write down the length of the second side of the triangle: "
INPUT length2
OUTPUT "Write down the length of the third side of the triangle: "
INPUT length3
ELSE IF (length1 = length2 AND length1 != length3) OR (length1 = length3 AND length1 != length2)
OR (length1 = length3 AND length1 != length2) OR (length2 = length3 AND length2 != length1)
ELSE
END IF
Pseudocode that identifies final price based on given percentage:
// The person writes their percentage, for example 40%. It is converted to 0.4 and then calculated!
INPUT Sale
Final_price = 25 + (25*(Sale/100))
INPUT NumMuffins
FinalPrice = NumMuffins * 2
IF NumMuffins <= 5
ELSE
ENDIF
Programming Construct: Determines the order in which lines of code are executed.
Types:
Selection: If statement, where on thing is done under one condition. It is a decision or question.
Types of selection:
IF..THEN..ENDIF
IF..THEN..ELSE..ENDIF
Conditional: True/False