Upcoming SlideShare
×

# Conditional statement ss1

3,262 views
2,937 views

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
3,262
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
19
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Conditional statement ss1

1. 1. Conditional Statement<br />
2. 2. Conditional Statements<br />Are statements that check an expression then may or may not execute a statement or group of statement depending on the result of the condition.<br />
3. 3. TYPES<br />IF-THEN STATEMENT<br />IF-THEN-ELSE STATEMENT<br />LADDERIZED IF-THEN-ELSE STATEMENT<br />
4. 4. IF-THEN STATEMENT<br />It specifies that a certain statement will be executed only if the expression is true<br />
5. 5. SYNTAX<br />IF condition THEN expression<br />
6. 6. Example<br />IF the telephone is ringing THEN<br />answer the telephone<br />
7. 7. RELATIONAL OPERATIONS<br />=<br />><br /><<br />>=<br /><=<br />
8. 8. SAMPLE PROBLEMS<br />
9. 9. Write a program that will output “Congratulations!” if the student’s grade is greater than or equal 75.<br />
10. 10. Rem<br />Clear<br />Input G<br />IF G>=75 THEN Print “Congratulations!”<br />End<br />
11. 11. 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.<br />
12. 12. Clear<br />Input P<br />If P>1000 THEN d=P*.1<br />Print d<br />End<br />
13. 13. IF-THEN-ELSE Statement <br />It allows the computer to choose one of the given two alternatives. <br />
14. 14. SYNTAX<br />IF condition THEN expression1 ELSE expression2<br />
15. 15. SAMPLE PROBLEMS<br />
16. 16. 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<br />
17. 17. REM<br />Clear<br />Input x,y<br />If x>y THEN S=x+y: Print S<br />ELSE<br />D=x-y : Print D<br />End<br />
18. 18. 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.<br />
19. 19. REM<br />Clear<br />Input A<br />If A>=18 THEN Print “Qualified to vote!”<br />ELSE Print “Too Young!”<br />End<br />
20. 20. NESTED IF or LADDERIZED IF-THEN-ELSE Statement<br />is used if there are three or more possible conditions and outcomes to be executed.<br />
21. 21. SYNTAX<br />IF condition1 THEN<br />Expression1<br />ELSE IF condition2 THEN<br />Expression N<br />ELSE<br />Expression<br />
22. 22. SAMPLE PROBLEMS<br />
23. 23. 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.<br />
24. 24. REM<br />Clear<br />Input x<br />IF x=b THEN Print “Blue”<br />ELSE IF x=r THEN Print “Red”<br />ELSE IF x=g THEN Print “Green”<br />ELSE IF x=y THEN Print “Yellow”<br />ELSE Print “Unknown Color!”<br />
25. 25. ASSIGNMENT<br />
26. 26. 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:<br />Year-Entry Number High School Level<br /> 1 Freshmen<br /> 2 Sophomore<br /> 3 Junior<br /> 4 Senior<br /> Other Entry No. Out-of-School<br />
27. 27. 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.<br />Temperature Message<br /> Less than 0 ICE<br />Between 0 and 100 Water<br /> Exceeds 100 STEAM<br />
28. 28. T. O. L.<br />