SlideShare a Scribd company logo
1 of 19
CSC240
INTRODUCTION TO PROGRAMMING – I
Mr. Dilawar
Lecturer,
Department of Computer Science,
Jahan University
Kabul, Afghanistan.
Previous Lecture Outline
• Variables
• Datatypes
• Declaration and Initialization of Variable
• Constants
• Defining and Using Constants
Lecture Outline
• Operators and Expressions
• Order of Precedence
• Statements and its Types
Operators
• A set of symbols that are used to perform an operation on values.
• C++ provides rich amount of operators such as
• Assignment and arithmetic operators
• Increment/decrement and arithmetic assignment operators
• Relational and comparison operations
• Logical and conditional operators
• Bitwise operators
• Manipulators and other miscellaneous operators
Assignment Operator
• This operator is used for assigning a
value to a variable.
• Assignment operator is =.
• Assigning the value/placing the value
in memory location – destructive and
reading back is called non-destructive.
int a, b, c = 10;
a = 25;
b = a;
Arithmetic Operators
• These operators are used to perform
arithmetic operations on the data such
as addition, subtraction, multiplication,
division and modulo operations.
• They can operate on both variables
and constants.
int a, b, c = 10;
a = 25;
c = a;
b = a + b;
// b = a – b;
// b = a * b;
Arithmetic Assignment Operators
• These operators are used to modify
the current value of a variable by
performing an operation on it.
• Arithmetic operation
• Assignment operation
• Arithmetic assignment operators are
+=, -=, *=, and /=.
int a, b, c = 10;
a = 50;
a += 40; //a = 90
b = 90;
B -= 40; //50;
Arithmetic Assignment Operators
• Look at the list below to better understand the concept:
Increment and Decrement Operators
• These operators are used to add or
subtract one value from the current
value of a variable.
• The increment operator is represented
by ++ and the decrement is
represented by --.
• It can be used either as postfix or
prefix notation.
int a = 50, b, c;
b = a + (++a); //prefix
c = a + (a++); //postfix
Relational or Comparison Operators
• These operators are used to show
relation among number.
• Common relational operators are >, <,
>=, <=, ==, and !=.
• The result can be either true (1) or
false (0).
int a = 50, b = 40;
cout<<(a<b); //return 0
cout<<(a>b); //return 1
Logical Operators
• These operators are used to combine
condition within a single statement.
• They are also called compound
operators.
• Logical operators are &&, ||, and !.
int a = 50, b = 40;
cout<<((a<b) && (a <80));
cout<<(a!=20);
Logical Operators
Implementation of AND Logical Operator
Implementation of OR Logical Operator
Conditional or Ternary Operators
• These operators are used to
return a value when a desired
condition is true or false.
• The common conditional
operators are ? And :.
int a = 50;
cout<<((a>10)?”T”:”F”);
Bitwise Operators
• These operators are used modify variables considering the bit
patterns that represent the values they store.
Manipulators
• These operators are used in C++
for formatting output.
• More commonly manipulators
are endl and setw.
• endl is used for line break.
• setw is used to set the width of an
output.
cout<“Welcome to”<<endl;
cout<<“Jahan
University”<<endl;
cout<<setw(8)<<“Name”<<se
tw(20)<<“Fname”<<endl;
Order of Precedence
• The order in which the arithmetic expression is evaluated is called the
order of precedence.
• Also known as hierarchy of operations.
• C++ expressions are performed in the following order:
• All multiplication and divisions are performed first from left to right.
• All additions and subtractions are then performed from left to right.
• If parenthesis are used in expression, the expressions are first computed.
• When parenthesis are used within parenthesis, the expression with
innermost parenthesis is evaluated first.
Order of Precedence
• For example (4-(3*5))+2 is evaluated as follows:
Summery
• Operators and Expressions
• Order of Precedence
• Statements and its Types
Thank You
For your Patience

More Related Content

What's hot

C operators
C operatorsC operators
C operatorsGPERI
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressionsvishaljot_kaur
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressionsvinay arora
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operatorsAnuja Lad
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++Shobi P P
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++Online
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Digvijaysinh Gohil
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in CPrabhu Govind
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++Pranav Ghildiyal
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operatorsdishti7
 
C language operators
C language operatorsC language operators
C language operatorsmarar hina
 

What's hot (18)

C operators
C operatorsC operators
C operators
 
Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Operators and expressions
Operators and expressionsOperators and expressions
Operators and expressions
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressions
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
Operators in C/C++
Operators in C/C++Operators in C/C++
Operators in C/C++
 
Operators
OperatorsOperators
Operators
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)Precedence and associativity (Computer programming and utilization)
Precedence and associativity (Computer programming and utilization)
 
Types of operators in C
Types of operators in CTypes of operators in C
Types of operators in C
 
CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++CBSE Class XI :- Operators in C++
CBSE Class XI :- Operators in C++
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
C language operators
C language operatorsC language operators
C language operators
 
Coper in C
Coper in CCoper in C
Coper in C
 
Relational operators
Relational operatorsRelational operators
Relational operators
 

Viewers also liked

Viewers also liked (13)

Chapter 01 networking
Chapter 01 networkingChapter 01 networking
Chapter 01 networking
 
Catella e-Crime London2015
Catella e-Crime London2015Catella e-Crime London2015
Catella e-Crime London2015
 
Six Super Simple Productivity Boosters
Six Super Simple Productivity BoostersSix Super Simple Productivity Boosters
Six Super Simple Productivity Boosters
 
Power Point SOP
Power Point SOPPower Point SOP
Power Point SOP
 
Bases curriculares lenguaje 2°
Bases curriculares lenguaje 2°Bases curriculares lenguaje 2°
Bases curriculares lenguaje 2°
 
Pdhpe slideshow pdf
Pdhpe slideshow pdfPdhpe slideshow pdf
Pdhpe slideshow pdf
 
Din cloud launched hosted sql server dinsql
Din cloud launched hosted sql server   dinsqlDin cloud launched hosted sql server   dinsql
Din cloud launched hosted sql server dinsql
 
Characterisation of Neuropeptide Signalling Systems in Learning
Characterisation of Neuropeptide Signalling Systems in LearningCharacterisation of Neuropeptide Signalling Systems in Learning
Characterisation of Neuropeptide Signalling Systems in Learning
 
Trabajo solo CTA 8vo "C"
Trabajo solo CTA 8vo "C"Trabajo solo CTA 8vo "C"
Trabajo solo CTA 8vo "C"
 
Norma la nube
Norma la nubeNorma la nube
Norma la nube
 
Sensores o2 demo
Sensores o2 demoSensores o2 demo
Sensores o2 demo
 
Issuers Story - PCI Congress London 23Jan14
Issuers Story - PCI Congress London 23Jan14Issuers Story - PCI Congress London 23Jan14
Issuers Story - PCI Congress London 23Jan14
 
Ethics at work place
Ethics at work placeEthics at work place
Ethics at work place
 

Similar to Csc240 -lecture_5 (20)

Operators in C#
Operators in C#Operators in C#
Operators in C#
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
OPERATORS IN C.pptx
OPERATORS IN C.pptxOPERATORS IN C.pptx
OPERATORS IN C.pptx
 
OPERATORS IN C.pptx
OPERATORS IN C.pptxOPERATORS IN C.pptx
OPERATORS IN C.pptx
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Operator overloading C++
Operator overloading C++Operator overloading C++
Operator overloading C++
 
Learn C# Programming - Operators
Learn C# Programming - OperatorsLearn C# Programming - Operators
Learn C# Programming - Operators
 
Chap 3(operator expression)
Chap 3(operator expression)Chap 3(operator expression)
Chap 3(operator expression)
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java script
 
C Building Blocks
C Building Blocks C Building Blocks
C Building Blocks
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
 
Theory3
Theory3Theory3
Theory3
 

More from Ainuddin Yousufzai

More from Ainuddin Yousufzai (15)

Chapter04 ip addressing networking
Chapter04 ip addressing networkingChapter04 ip addressing networking
Chapter04 ip addressing networking
 
Chapter 02 topology networking
Chapter 02  topology networkingChapter 02  topology networking
Chapter 02 topology networking
 
Chapter08 internet &amp; multimedia (b)
Chapter08   internet &amp; multimedia (b)Chapter08   internet &amp; multimedia (b)
Chapter08 internet &amp; multimedia (b)
 
Chapter08 internet &amp; multimedia (a)
Chapter08   internet &amp; multimedia (a)Chapter08   internet &amp; multimedia (a)
Chapter08 internet &amp; multimedia (a)
 
Chapter07 io devices
Chapter07   io devicesChapter07   io devices
Chapter07 io devices
 
Chapter06 computer software
Chapter06   computer softwareChapter06   computer software
Chapter06 computer software
 
Chapter05 secondary storage
Chapter05   secondary storageChapter05   secondary storage
Chapter05 secondary storage
 
Chapter04 processor and memory
Chapter04   processor and memoryChapter04   processor and memory
Chapter04 processor and memory
 
Chapter03 number system
Chapter03   number systemChapter03   number system
Chapter03 number system
 
Chapter02 basic computer organization
Chapter02   basic computer organizationChapter02   basic computer organization
Chapter02 basic computer organization
 
Chapter01 introduction to computer
Chapter01   introduction to computerChapter01   introduction to computer
Chapter01 introduction to computer
 
Csc240 -lecture_4
Csc240  -lecture_4Csc240  -lecture_4
Csc240 -lecture_4
 
Csc240 -lecture_3
Csc240  -lecture_3Csc240  -lecture_3
Csc240 -lecture_3
 
Csc240 -lecture_2
Csc240  -lecture_2Csc240  -lecture_2
Csc240 -lecture_2
 
Csc240 lecture 1
Csc240   lecture 1Csc240   lecture 1
Csc240 lecture 1
 

Recently uploaded

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
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🔝
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
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🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 

Csc240 -lecture_5

  • 1. CSC240 INTRODUCTION TO PROGRAMMING – I Mr. Dilawar Lecturer, Department of Computer Science, Jahan University Kabul, Afghanistan.
  • 2. Previous Lecture Outline • Variables • Datatypes • Declaration and Initialization of Variable • Constants • Defining and Using Constants
  • 3. Lecture Outline • Operators and Expressions • Order of Precedence • Statements and its Types
  • 4. Operators • A set of symbols that are used to perform an operation on values. • C++ provides rich amount of operators such as • Assignment and arithmetic operators • Increment/decrement and arithmetic assignment operators • Relational and comparison operations • Logical and conditional operators • Bitwise operators • Manipulators and other miscellaneous operators
  • 5. Assignment Operator • This operator is used for assigning a value to a variable. • Assignment operator is =. • Assigning the value/placing the value in memory location – destructive and reading back is called non-destructive. int a, b, c = 10; a = 25; b = a;
  • 6. Arithmetic Operators • These operators are used to perform arithmetic operations on the data such as addition, subtraction, multiplication, division and modulo operations. • They can operate on both variables and constants. int a, b, c = 10; a = 25; c = a; b = a + b; // b = a – b; // b = a * b;
  • 7. Arithmetic Assignment Operators • These operators are used to modify the current value of a variable by performing an operation on it. • Arithmetic operation • Assignment operation • Arithmetic assignment operators are +=, -=, *=, and /=. int a, b, c = 10; a = 50; a += 40; //a = 90 b = 90; B -= 40; //50;
  • 8. Arithmetic Assignment Operators • Look at the list below to better understand the concept:
  • 9. Increment and Decrement Operators • These operators are used to add or subtract one value from the current value of a variable. • The increment operator is represented by ++ and the decrement is represented by --. • It can be used either as postfix or prefix notation. int a = 50, b, c; b = a + (++a); //prefix c = a + (a++); //postfix
  • 10. Relational or Comparison Operators • These operators are used to show relation among number. • Common relational operators are >, <, >=, <=, ==, and !=. • The result can be either true (1) or false (0). int a = 50, b = 40; cout<<(a<b); //return 0 cout<<(a>b); //return 1
  • 11. Logical Operators • These operators are used to combine condition within a single statement. • They are also called compound operators. • Logical operators are &&, ||, and !. int a = 50, b = 40; cout<<((a<b) && (a <80)); cout<<(a!=20);
  • 12. Logical Operators Implementation of AND Logical Operator Implementation of OR Logical Operator
  • 13. Conditional or Ternary Operators • These operators are used to return a value when a desired condition is true or false. • The common conditional operators are ? And :. int a = 50; cout<<((a>10)?”T”:”F”);
  • 14. Bitwise Operators • These operators are used modify variables considering the bit patterns that represent the values they store.
  • 15. Manipulators • These operators are used in C++ for formatting output. • More commonly manipulators are endl and setw. • endl is used for line break. • setw is used to set the width of an output. cout<“Welcome to”<<endl; cout<<“Jahan University”<<endl; cout<<setw(8)<<“Name”<<se tw(20)<<“Fname”<<endl;
  • 16. Order of Precedence • The order in which the arithmetic expression is evaluated is called the order of precedence. • Also known as hierarchy of operations. • C++ expressions are performed in the following order: • All multiplication and divisions are performed first from left to right. • All additions and subtractions are then performed from left to right. • If parenthesis are used in expression, the expressions are first computed. • When parenthesis are used within parenthesis, the expression with innermost parenthesis is evaluated first.
  • 17. Order of Precedence • For example (4-(3*5))+2 is evaluated as follows:
  • 18. Summery • Operators and Expressions • Order of Precedence • Statements and its Types
  • 19. Thank You For your Patience