IF-THEN STATEMENT It specifies that a certain statement will be executed only if the expression is true
SYNTAX IF condition THEN expression
Example IF the telephone is ringing THEN answer the telephone
RELATIONAL OPERATIONS = > < >= <=
Write a program that will output “Congratulations!” if the student’s grade is greater than or equal 75.
Rem Clear Input G IF G>=75 THEN Print “Congratulations!” End
Write a program that will ask for a price. If the price is greater than 1000, compute a 10% discount from the original price. Display the computed discount.
Clear Input P If P>1000 THEN d=P*.1 Print d End
IF-THEN-ELSE Statement It allows the computer to choose one of the given two alternatives.
SYNTAX IF condition THEN expression1 ELSE expression2
Write a program to print for the sum of two numbers if the first no. is greater than the second no., otherwise print their difference
REM Clear Input x,y If x>y THEN S=x+y: Print S ELSE D=x-y : Print D End
Write a program that determines if the input age is qualified to vote or not. If qualified, displays “Qualified to Vote!” if not displays “Too Young!” We know that a qualifying age is 18 yrs. old and above.
REM Clear Input A If A>=18 THEN Print “Qualified to vote!” ELSE Print “Too Young!” End
NESTED IF or LADDERIZED IF-THEN-ELSE Statement is used if there are three or more possible conditions and outcomes to be executed.
SYNTAX IF condition1 THEN Expression1 ELSE IF condition2 THEN Expression N ELSE Expression
Write a program that displays an equivalent color once an input letter matches its first character for example b is for blue, r for red and so on. Here is the given criteria.
REM Clear Input x IF x=b THEN Print “Blue” ELSE IF x=r THEN Print “Red” ELSE IF x=g THEN Print “Green” ELSE IF x=y THEN Print “Yellow” ELSE Print “Unknown Color!”
Write a program to display the high school level of a student, based on its year entry number for example the year-entry 1 means the student is a freshmen, 2 for sophomore, and so on. Here are the given criteria: Year-Entry Number High School Level 1 Freshmen 2 Sophomore 3 Junior 4 Senior Other Entry No. Out-of-School
Write a program that examine the value of a variable called temp. then display the following messages depending on the value assigned to the temp. Temperature Message Less than 0 ICE Between 0 and 100 Water Exceeds 100 STEAM