SlideShare a Scribd company logo
1 of 8
LECTURE 12
BY: RUBYNA VOHRA
C# EXPRESSIONS
WHAT’S AN EXPRESSION?
In Math...
“Phrase” that can contain numbers,
variables (x,y,z,etc.) and operators
(add,subtract,multiply, and divide).
Example:
• a + 1
• a – b
• 3x
• x - a / b
IN COMPUTER SCIENCE AN EXPRESSION IS…
The same as it is in math!
Except…with a few added operators
OPERATORS
Subtraction -
Addition +
Multiplication *
Division /
Modulo (mod) %
Less than <
Less Than or Equal to <=
Greater than >
Greater than or Equal to >=
AND &&
OR ||
Not Equal !=
Equal Equal ==
Not !
PRECEDENCE
• Similar to PEMDAS in math
• Parentheses
• Exponents
• Multiplication/Division (left to right)
• Addition/Subtraction (left to right)
• Parentheses
• Modulo (Mod)
• Multiplication/Division (left to right)
• Addition/Subtraction (left to right)
• Boolean Logic such as
|| OR
&& AND
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
!= Not Equal
= Equal
! Not
The Computer Science Version
A FEW EXAMPLES
Expression Value
1)3 + 3 + “six” + (3 + 3) * 3 % 3
2)(11 != 7 + 4 || 3 * 2 <= 39 % 10) == false
*Answer Key with Steps will be posted online under “Lecture Materials”
GROUP WORK
• Get to know each other
• Solve these problems…
• 15-20 min
• Share out
5 * 6 - (4 + 3) * 2 - 2 * 3
208 / 20 / 4 + 12 / 10.0 + 0.4 * 24.0
8 - 2 + "8 - 2" + 8 * 2 + 8 "68 - 2168"
4 * 5 % 6 + 297 % 10 + 4 % 813
13 / 2 * 3.0 + 5.5 * 3 / 226.25

More Related Content

What's hot

Number system
Number systemNumber system
Number systemkaramnav
 
Y7 m280115workw ithnumb1
Y7 m280115workw ithnumb1Y7 m280115workw ithnumb1
Y7 m280115workw ithnumb13SNEducation
 
Real numbers system
Real numbers systemReal numbers system
Real numbers systemwfmcmillian
 
Rational functions
Rational functionsRational functions
Rational functionsjennahall1
 
Tips And Tricks For The Ap Calculus Exam
Tips And Tricks For The Ap Calculus ExamTips And Tricks For The Ap Calculus Exam
Tips And Tricks For The Ap Calculus Examkmiksch
 
Real Numbers
Real NumbersReal Numbers
Real NumbersSarah525
 
Algebra 101 real numbers and the real number line
Algebra 101 real numbers and the real number lineAlgebra 101 real numbers and the real number line
Algebra 101 real numbers and the real number lineChloeDaniel2
 
The real number system
The real number systemThe real number system
The real number systemShawn Burke
 

What's hot (20)

Real Number System
Real Number SystemReal Number System
Real Number System
 
04 real numbers
04   real numbers04   real numbers
04 real numbers
 
Rational numbers
Rational numbersRational numbers
Rational numbers
 
Number system
Number systemNumber system
Number system
 
Real Numbers
Real NumbersReal Numbers
Real Numbers
 
Rational numbers
Rational numbersRational numbers
Rational numbers
 
Y7 m280115workw ithnumb1
Y7 m280115workw ithnumb1Y7 m280115workw ithnumb1
Y7 m280115workw ithnumb1
 
The real number system
The real number systemThe real number system
The real number system
 
Real numbers system
Real numbers systemReal numbers system
Real numbers system
 
Rational functions
Rational functionsRational functions
Rational functions
 
Tips And Tricks For The Ap Calculus Exam
Tips And Tricks For The Ap Calculus ExamTips And Tricks For The Ap Calculus Exam
Tips And Tricks For The Ap Calculus Exam
 
Real Numbers
Real NumbersReal Numbers
Real Numbers
 
Roshdy salem
Roshdy salemRoshdy salem
Roshdy salem
 
The Real Numbers
The Real NumbersThe Real Numbers
The Real Numbers
 
Rational Numbers
Rational NumbersRational Numbers
Rational Numbers
 
Algebra 101 real numbers and the real number line
Algebra 101 real numbers and the real number lineAlgebra 101 real numbers and the real number line
Algebra 101 real numbers and the real number line
 
The real number system
The real number systemThe real number system
The real number system
 
Ppt on real numbers
Ppt on real numbersPpt on real numbers
Ppt on real numbers
 
Real number system
Real number systemReal number system
Real number system
 
NUMBER SYSTEM
NUMBER SYSTEMNUMBER SYSTEM
NUMBER SYSTEM
 

More from Skillspire LLC (20)

Logistics
LogisticsLogistics
Logistics
 
Introduction to analytics
Introduction to analyticsIntroduction to analytics
Introduction to analytics
 
Lecture 31
Lecture 31Lecture 31
Lecture 31
 
Lecture 30
Lecture 30Lecture 30
Lecture 30
 
Lecture 29
Lecture 29Lecture 29
Lecture 29
 
Review
ReviewReview
Review
 
Review version 4
Review version 4Review version 4
Review version 4
 
Review version 3
Review version 3Review version 3
Review version 3
 
Review version 2
Review version 2Review version 2
Review version 2
 
Lecture 25
Lecture 25Lecture 25
Lecture 25
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23 p1
Lecture 23 p1Lecture 23 p1
Lecture 23 p1
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 15
Lecture 15Lecture 15
Lecture 15
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 13
Lecture 13Lecture 13
Lecture 13
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
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
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 

Lecture 12

  • 3. WHAT’S AN EXPRESSION? In Math... “Phrase” that can contain numbers, variables (x,y,z,etc.) and operators (add,subtract,multiply, and divide). Example: • a + 1 • a – b • 3x • x - a / b
  • 4. IN COMPUTER SCIENCE AN EXPRESSION IS… The same as it is in math! Except…with a few added operators
  • 5. OPERATORS Subtraction - Addition + Multiplication * Division / Modulo (mod) % Less than < Less Than or Equal to <= Greater than > Greater than or Equal to >= AND && OR || Not Equal != Equal Equal == Not !
  • 6. PRECEDENCE • Similar to PEMDAS in math • Parentheses • Exponents • Multiplication/Division (left to right) • Addition/Subtraction (left to right) • Parentheses • Modulo (Mod) • Multiplication/Division (left to right) • Addition/Subtraction (left to right) • Boolean Logic such as || OR && AND < Less than <= Less than or equal to > Greater than >= Greater than or equal to != Not Equal = Equal ! Not The Computer Science Version
  • 7. A FEW EXAMPLES Expression Value 1)3 + 3 + “six” + (3 + 3) * 3 % 3 2)(11 != 7 + 4 || 3 * 2 <= 39 % 10) == false *Answer Key with Steps will be posted online under “Lecture Materials”
  • 8. GROUP WORK • Get to know each other • Solve these problems… • 15-20 min • Share out 5 * 6 - (4 + 3) * 2 - 2 * 3 208 / 20 / 4 + 12 / 10.0 + 0.4 * 24.0 8 - 2 + "8 - 2" + 8 * 2 + 8 "68 - 2168" 4 * 5 % 6 + 297 % 10 + 4 % 813 13 / 2 * 3.0 + 5.5 * 3 / 226.25