SlideShare une entreprise Scribd logo
1  sur  28
Conditional Statement
Conditional Statements 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.
TYPES IF-THEN STATEMENT IF-THEN-ELSE STATEMENT LADDERIZED IF-THEN-ELSE STATEMENT
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 = > < >= <=
SAMPLE PROBLEMS
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
SAMPLE PROBLEMS
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
SAMPLE PROBLEMS
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!”
ASSIGNMENT
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
T. O. L.

Contenu connexe

Similaire à Conditional statement ss1

Programming fundamentals lecture 3
Programming fundamentals lecture 3Programming fundamentals lecture 3
Programming fundamentals lecture 3Raja Hamid
 
Working with comparison operators
Working with comparison operatorsWorking with comparison operators
Working with comparison operatorsSara Corpuz
 
Conditional statements
Conditional statementsConditional statements
Conditional statementscherrybear2014
 
Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01Nurhidayah Mahmud
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.pptFerdieBalang
 

Similaire à Conditional statement ss1 (8)

How to Program
How to ProgramHow to Program
How to Program
 
Programming fundamentals lecture 3
Programming fundamentals lecture 3Programming fundamentals lecture 3
Programming fundamentals lecture 3
 
MA3696 Lecture 7
MA3696 Lecture 7MA3696 Lecture 7
MA3696 Lecture 7
 
Working with comparison operators
Working with comparison operatorsWorking with comparison operators
Working with comparison operators
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01Reportgroup4 111016004939-phpapp01
Reportgroup4 111016004939-phpapp01
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt
 

Plus de Jordan Delacruz (19)

Novel analysis
Novel analysisNovel analysis
Novel analysis
 
Motion tween resize
Motion tween resizeMotion tween resize
Motion tween resize
 
Computer motion tween
Computer motion tweenComputer motion tween
Computer motion tween
 
Introduction to layers
Introduction to layersIntroduction to layers
Introduction to layers
 
Graphics
GraphicsGraphics
Graphics
 
(Sept.14)
(Sept.14)(Sept.14)
(Sept.14)
 
(Sept.7)
(Sept.7)(Sept.7)
(Sept.7)
 
(Sept.5)
(Sept.5)(Sept.5)
(Sept.5)
 
(Sept. 8)
(Sept. 8)(Sept. 8)
(Sept. 8)
 
(Sept6. )
(Sept6. )(Sept6. )
(Sept6. )
 
(Sept15.)demo
(Sept15.)demo(Sept15.)demo
(Sept15.)demo
 
(Aug.31) introduction to macflash
(Aug.31) introduction to macflash(Aug.31) introduction to macflash
(Aug.31) introduction to macflash
 
(Sept.1) environment
(Sept.1) environment(Sept.1) environment
(Sept.1) environment
 
Introduction to basic programming repetition
Introduction to basic programming repetitionIntroduction to basic programming repetition
Introduction to basic programming repetition
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchart
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 

Dernier

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Dernier (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Conditional statement ss1

  • 2. Conditional Statements 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.
  • 3. TYPES IF-THEN STATEMENT IF-THEN-ELSE STATEMENT LADDERIZED IF-THEN-ELSE STATEMENT
  • 4. IF-THEN STATEMENT It specifies that a certain statement will be executed only if the expression is true
  • 5. SYNTAX IF condition THEN expression
  • 6. Example IF the telephone is ringing THEN answer the telephone
  • 9. Write a program that will output “Congratulations!” if the student’s grade is greater than or equal 75.
  • 10. Rem Clear Input G IF G>=75 THEN Print “Congratulations!” End
  • 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.
  • 12. Clear Input P If P>1000 THEN d=P*.1 Print d End
  • 13. IF-THEN-ELSE Statement It allows the computer to choose one of the given two alternatives.
  • 14. SYNTAX IF condition THEN expression1 ELSE expression2
  • 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
  • 17. REM Clear Input x,y If x>y THEN S=x+y: Print S ELSE D=x-y : Print D End
  • 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.
  • 19. REM Clear Input A If A>=18 THEN Print “Qualified to vote!” ELSE Print “Too Young!” End
  • 20. NESTED IF or LADDERIZED IF-THEN-ELSE Statement is used if there are three or more possible conditions and outcomes to be executed.
  • 21. SYNTAX IF condition1 THEN Expression1 ELSE IF condition2 THEN Expression N ELSE Expression
  • 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.
  • 24. 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!”
  • 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: Year-Entry Number High School Level 1 Freshmen 2 Sophomore 3 Junior 4 Senior Other Entry No. Out-of-School
  • 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. Temperature Message Less than 0 ICE Between 0 and 100 Water Exceeds 100 STEAM