Upcoming SlideShare
×

# Conditional statement ss2

2,978 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

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

• Be the first to like this

Views
Total views
2,978
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
20
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Conditional statement ss2

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. 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 />
11. 11. IF-THEN-ELSE Statement <br />It allows the computer to choose one of the given two alternatives. <br />
12. 12. SYNTAX<br />IF condition THEN expression1 ELSE expression2<br />
13. 13. SAMPLE PROBLEMS<br />
14. 14. 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 />
15. 15. 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 />
16. 16. 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 />
17. 17. SYNTAX<br />IF condition1 THEN<br />Expression1<br />ELSE IF condition2 THEN<br />Expression N<br />ELSE<br />Expression<br />
18. 18. SAMPLE PROBLEMS<br />
19. 19. 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 />
20. 20. ASSIGNMENT<br />
21. 21. 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 />
22. 22. 2. Write a program that examines 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 />