SlideShare uma empresa Scribd logo
1 de 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.

Mais conteúdo relacionado

Semelhante a Conditional statement ss1

Semelhante a 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
 

Mais 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
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 

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