SlideShare a Scribd company logo
1 of 23
Lab 4
CS106 - Fundamentals of Computer Science
Presented by TA. Nada Kamel
Agenda
 ASCII Table
 Relational Operators
 Logical Operators
 If/else condition
 Multiway if/else condition
 Example
 Hands-on problems
Presented by TA. Nada Kamel
ASCII Table
Presented by TA. Nada Kamel
ASCII Table
Presented by TA. Nada Kamel
Relational Operators
Presented by TA. Nada Kamel
Relational Operators
Relational Operator Description
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
Presented by TA. Nada Kamel
Logical Operators
Presented by TA. Nada Kamel
Logical Operators
Logical Operator Description
! not
&& and
|| or
Presented by TA. Nada Kamel
If/else
Presented by TA. Nada Kamel
if/else flowchart
Presented by TA. Nada Kamel
If/else
if(boolean_expression)
{
// statement(s) will execute if the boolean expression is true
}
else
{
// statement(s) will execute if the boolean expression is false
}
Presented by TA. Nada Kamel
Boolean Expressions
 if (a == 5)
an expression to check if the value of a is equal to 5
 if (a*b >= c)
an expression to check if the value of a multiply by b is greater than or equal to
the value of c
 if (my_char == ’s’)
an expression to check if the value of my_char is equal to ‘s’
 if (a == 8 && b == 3)
an expression to check if the value of a is equal to 8 and the value of
b is equal to 3
Presented by TA. Nada Kamel
Multiway if/else
Presented by TA. Nada Kamel
Multiway if/else
if(boolean_expression_1)
{
// statements to be executed if the first boolean expression is true
}
else if(boolean_expression_2)
{
// statements to be executed if the first boolean expression is false and the
second boolean expression is true
}
..
..
else
{
// statements to be executed if all test expressions are false
}
Presented by TA. Nada Kamel
Example
Presented by TA. Nada Kamel
Example
Write a program in C++ that reads three scores of a student in
three tests to compute and display the largest score.
Presented by TA. Nada Kamel
Hands-on Problem
Presented by TA. Nada Kamel
Problem 1
Write a program in C++ that reads a positive integer number to
notify the user with a message whether the integer number Even
or Odd.
Presented by TA. Nada Kamel
Problem 2
 Community Hospital needs a program to compute and print a statement for each
patient.
 Charges for each day are as follows:
a) Room charges: private room, $125.00; semiprivate room, $95.00; or ward, $75.00
b) Telephone charge: $1.75
c) Television charge: $3.50
 Write a program to get one string of four characters from the keyboard, the first
character is an integer value indicating the number of days spent in the hospital,
and the others are three alphabet characters.
 Typical input is: 5PNY
where 5 indicates the number of days spent in the hospital, P represents the room
type (P, S, or W), N represents the telephone option (Y or N), and Y represents the
television option (Y or N).
Presented by TA. Nada Kamel
Any Questions?
Presented by TA. Nada Kamel

More Related Content

What's hot

What's hot (18)

Java -lec-5
Java -lec-5Java -lec-5
Java -lec-5
 
Daa
DaaDaa
Daa
 
Why you should use a testing framework
Why you should use a testing frameworkWhy you should use a testing framework
Why you should use a testing framework
 
Code Tuning
Code TuningCode Tuning
Code Tuning
 
Arrays c4 c5
Arrays c4 c5Arrays c4 c5
Arrays c4 c5
 
Johnson Trotter Algorithm(Permutation)
Johnson Trotter Algorithm(Permutation)Johnson Trotter Algorithm(Permutation)
Johnson Trotter Algorithm(Permutation)
 
Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
 
Function procedure c6 c7
Function procedure  c6 c7Function procedure  c6 c7
Function procedure c6 c7
 
Evaluation of prefix expression with example
Evaluation of prefix expression with exampleEvaluation of prefix expression with example
Evaluation of prefix expression with example
 
Data structures and algorithms lab3
Data structures and algorithms lab3Data structures and algorithms lab3
Data structures and algorithms lab3
 
Lecture4
Lecture4Lecture4
Lecture4
 
Hw5 2017-spring
Hw5 2017-springHw5 2017-spring
Hw5 2017-spring
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Lecture05 abap on line
Lecture05 abap on lineLecture05 abap on line
Lecture05 abap on line
 
Effective java item 80 and 81
Effective java   item 80 and 81Effective java   item 80 and 81
Effective java item 80 and 81
 
Overriding methods
Overriding methodsOverriding methods
Overriding methods
 
09 advanced c#
09 advanced c#09 advanced c#
09 advanced c#
 
Insertion sort
Insertion sort Insertion sort
Insertion sort
 

Similar to CS106 Lab 4 Operators Conditions Titles ASCII Relational Logical If Else Multiway

1 Computer Assignment 3 --- Hypothesis tests about m.docx
1 Computer Assignment 3     ---   Hypothesis tests about m.docx1 Computer Assignment 3     ---   Hypothesis tests about m.docx
1 Computer Assignment 3 --- Hypothesis tests about m.docxmercysuttle
 
Orthogonal array testing
Orthogonal array testingOrthogonal array testing
Orthogonal array testingPrince Bhanwra
 
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_iiCsci101 lect07 algorithms_ii
Csci101 lect07 algorithms_iiElsayed Hemayed
 
· Assignment 1. Linear Programming Case StudyYour instruct.docx
· Assignment 1. Linear Programming Case StudyYour instruct.docx· Assignment 1. Linear Programming Case StudyYour instruct.docx
· Assignment 1. Linear Programming Case StudyYour instruct.docxLynellBull52
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and SelectionAhmed Nobi
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional StatementsIntro C# Book
 
Lec16.pptx problem specifications computer
Lec16.pptx problem specifications computerLec16.pptx problem specifications computer
Lec16.pptx problem specifications computersamiullahamjad06
 
C programming assignment presentation file
C programming assignment presentation fileC programming assignment presentation file
C programming assignment presentation filesantoshkumarhpu
 
D-Pubb-TestingExperience_Issue_28_2014-12_Berta
D-Pubb-TestingExperience_Issue_28_2014-12_BertaD-Pubb-TestingExperience_Issue_28_2014-12_Berta
D-Pubb-TestingExperience_Issue_28_2014-12_BertaBerta Danilo
 
Module code 124ms Tajvinder Virdee Sets and Log.docx
Module code 124ms  Tajvinder Virdee  Sets and Log.docxModule code 124ms  Tajvinder Virdee  Sets and Log.docx
Module code 124ms Tajvinder Virdee Sets and Log.docxmoirarandell
 
Testing lab manual Testing lab manual sqa
Testing lab manual Testing lab manual sqaTesting lab manual Testing lab manual sqa
Testing lab manual Testing lab manual sqaMuhammadAdnan845624
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxgerardkortney
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 

Similar to CS106 Lab 4 Operators Conditions Titles ASCII Relational Logical If Else Multiway (20)

06
0606
06
 
1 Computer Assignment 3 --- Hypothesis tests about m.docx
1 Computer Assignment 3     ---   Hypothesis tests about m.docx1 Computer Assignment 3     ---   Hypothesis tests about m.docx
1 Computer Assignment 3 --- Hypothesis tests about m.docx
 
Orthogonal array testing
Orthogonal array testingOrthogonal array testing
Orthogonal array testing
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_iiCsci101 lect07 algorithms_ii
Csci101 lect07 algorithms_ii
 
· Assignment 1. Linear Programming Case StudyYour instruct.docx
· Assignment 1. Linear Programming Case StudyYour instruct.docx· Assignment 1. Linear Programming Case StudyYour instruct.docx
· Assignment 1. Linear Programming Case StudyYour instruct.docx
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
Perl_Part2
Perl_Part2Perl_Part2
Perl_Part2
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional Statements
 
MA3696 Lecture 7
MA3696 Lecture 7MA3696 Lecture 7
MA3696 Lecture 7
 
Lec16.pptx problem specifications computer
Lec16.pptx problem specifications computerLec16.pptx problem specifications computer
Lec16.pptx problem specifications computer
 
C programming assignment presentation file
C programming assignment presentation fileC programming assignment presentation file
C programming assignment presentation file
 
D-Pubb-TestingExperience_Issue_28_2014-12_Berta
D-Pubb-TestingExperience_Issue_28_2014-12_BertaD-Pubb-TestingExperience_Issue_28_2014-12_Berta
D-Pubb-TestingExperience_Issue_28_2014-12_Berta
 
Module code 124ms Tajvinder Virdee Sets and Log.docx
Module code 124ms  Tajvinder Virdee  Sets and Log.docxModule code 124ms  Tajvinder Virdee  Sets and Log.docx
Module code 124ms Tajvinder Virdee Sets and Log.docx
 
Testing lab manual Testing lab manual sqa
Testing lab manual Testing lab manual sqaTesting lab manual Testing lab manual sqa
Testing lab manual Testing lab manual sqa
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
 
Lab5
Lab5Lab5
Lab5
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
03. Week 03.pptx
03. Week 03.pptx03. Week 03.pptx
03. Week 03.pptx
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

CS106 Lab 4 Operators Conditions Titles ASCII Relational Logical If Else Multiway

  • 1. Lab 4 CS106 - Fundamentals of Computer Science Presented by TA. Nada Kamel
  • 2. Agenda  ASCII Table  Relational Operators  Logical Operators  If/else condition  Multiway if/else condition  Example  Hands-on problems Presented by TA. Nada Kamel
  • 3. ASCII Table Presented by TA. Nada Kamel
  • 4. ASCII Table Presented by TA. Nada Kamel
  • 6. Relational Operators Relational Operator Description == Equal to != Not equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to Presented by TA. Nada Kamel
  • 8. Logical Operators Logical Operator Description ! not && and || or Presented by TA. Nada Kamel
  • 11. If/else if(boolean_expression) { // statement(s) will execute if the boolean expression is true } else { // statement(s) will execute if the boolean expression is false } Presented by TA. Nada Kamel
  • 12. Boolean Expressions  if (a == 5) an expression to check if the value of a is equal to 5  if (a*b >= c) an expression to check if the value of a multiply by b is greater than or equal to the value of c  if (my_char == ’s’) an expression to check if the value of my_char is equal to ‘s’  if (a == 8 && b == 3) an expression to check if the value of a is equal to 8 and the value of b is equal to 3 Presented by TA. Nada Kamel
  • 14. Multiway if/else if(boolean_expression_1) { // statements to be executed if the first boolean expression is true } else if(boolean_expression_2) { // statements to be executed if the first boolean expression is false and the second boolean expression is true } .. .. else { // statements to be executed if all test expressions are false } Presented by TA. Nada Kamel
  • 16. Example Write a program in C++ that reads three scores of a student in three tests to compute and display the largest score. Presented by TA. Nada Kamel
  • 17.
  • 19. Problem 1 Write a program in C++ that reads a positive integer number to notify the user with a message whether the integer number Even or Odd. Presented by TA. Nada Kamel
  • 20.
  • 21. Problem 2  Community Hospital needs a program to compute and print a statement for each patient.  Charges for each day are as follows: a) Room charges: private room, $125.00; semiprivate room, $95.00; or ward, $75.00 b) Telephone charge: $1.75 c) Television charge: $3.50  Write a program to get one string of four characters from the keyboard, the first character is an integer value indicating the number of days spent in the hospital, and the others are three alphabet characters.  Typical input is: 5PNY where 5 indicates the number of days spent in the hospital, P represents the room type (P, S, or W), N represents the telephone option (Y or N), and Y represents the television option (Y or N). Presented by TA. Nada Kamel
  • 22.
  • 23. Any Questions? Presented by TA. Nada Kamel