SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Slide 1
Slide 2
Expressions
In C++, there are many special characters with particular
meanings. Examples include the arithmetic operators:
Relational, Equality, and Logical Operators
Just as with other operators, the relational, equality, and logical operators
have rules of precedence and associativity that determine precisely how
expressions involving them are evaluated. C++ systems use the bool values
true and false to direct the flow of control in the various statement types.
Slide 3
Expressions
Relational, Equality, and Logical Operators
the relational, equality, and logical operators have rules of precedence and
associativity that determine precisely how expressions involving them are
evaluated. C++ systems use the bool values true and false to direct the flow
of control in the various statement types.
Slide 4
Expressions
Logical AND (&&)
p q p && q
T T
T F
F T
F F
Slide 5
Expressions
Logical AND (&&)
p q p && q
T T T
T F F
F T F
F F F
Slide 6
Expressions
Logical OR
p q p || q
T T
T F
F T
F F
Slide 7
Expressions
Logical OR
p q p || q
T T T
T F T
F T T
F F F
Slide 8
Expressions
Logical negation
p !p
T
F
Slide 9
Expressions
Logical negation
p !p
T F
F T
Bitwise Operators
Slide 10
Bitwise operation means convert the number into binary and the carry out the
operation on each bit individually. For example let us take the operation
complement represented by symbol (~). Let me take a number
short A = 42;
A short number is stored in two byte or 16 bits. Therefore,
A when expressed in binary = 00000000 00101010
Complement of A is ~A = 11111111 11010101
Contd...
Slide 11
Bitwise Operators
Slide 12
#include<iostream>
using namespace std;
void main()
{ short A =42;
short B = 12;
int C = A|B;
int D = A<<1;
cout << "C = "<<C <<endl;
cout<< "D = "<<D <<endl;
}
Bitwise Operators
The expected output is as under.
C = 46
D = 84
Slide 13
#include<iostream>
using namespace std;
void main()
{short A =42;
short B = 12;
short C = 24;
short D = A^B; // XOR operator
C <<= 1;
A <<=2; // Shift to left by 2 places and assign
B >>=2 ; // shift right by 2 places and assign
cout<< "A = "<<A<< " tB = "<< B <<endl;
cout << "C = "<<C <<endl;
cout << "D = "<< D <<endl;
}
The expected output is given below.
A = 168 B = 3
C = 48
D = 38
Operators common to C++
Slide 14
Slide 15
Operator Precedence
In C++, you use operators and expressions such as the following:
int MyNumber = 10 * 30 + 20 – 5 * 5 << 2;
The question is, what value would MyNumber contain? The order in which the
various operators are invoked is very strictly specified by the C++ standard.
This order is what is meant by operator precedence.
Slide 16
Slide 17
Assignment and Expressions
C++ provides assignment operators that combine an assignment operator
and some other operator.
C++ also provides increment (++) and decrement (--) operators in both
prefix and postfix form.
Slide 18
Assignment and Expressions
The postfix form behaves differently from the prefix form:
Slide 19
PROGRAMMING WITH VISUAL C++
C++ Relational, Equality, and Logical
Slide 20
PROGRAMMING WITH VISUAL C++
C++ Relational, Equality, and Logical
Slide 21
PROGRAMMING WITH VISUAL C++
C++ Relational, Equality, and Logical
Slide 22
Statements
C++ has a large variety of statement types, including an
expression statement. For example, the assignment
statement in C++ is syntactically an assignment expression
followed by a semicolon.
There are two
statements:
The Simple
Statement
The Compound
Statement
Slide 23
The Compound Statement
The Compound Statement
• A compound statement in C++ is a series of statements
surrounded by braces { and }.
• The body of a C++ function, for example, is always a compound
statement.
Conditional ternary operator ( ? )
Slide 24
The conditional operator evaluates an expression, returning first value if that
expression evaluates to true, and a different one if the expression evaluates as
false. Its syntax is:
condition ? result1 : result2
7==5 ? 4 : 3 // evaluates to 3, since 7 is not equal to 5.
7==5+2 ? 4 : 3 // evaluates to 4, since 7 is equal to 5+2.
5>3 ? a : b // evaluates to the value of a, since 5 is greater than 3.
a>b ? a : b // evaluates to whichever is greater, a or b.
Slide 25
For example:
// conditional operator
#include <iostream>
using namespace std;
int main ()
{
int a,b,c;
a=2;
b=7;
c = (a>b) ? a : b;
cout << c << 'n';
}
In this example, a was 2, and b was 7, so the expression being evaluated (a>b)
was not true, thus the first value specified after the question mark was discarded
in favor of the second value (the one after the colon) which was b (with a value
of 7).
Slide 26
The if and if-else Statements
if and if-else
The general form of an if statement is:
Here is an example of an if statement:
Or another example:
Slide 27
Closely related to the if statement is the if-else statement,
which has the general form
if and if-else
Slide 28
If condition is true, then statement1 is executed and
statement2 is skipped; if condition is false, then
statement1 is skipped and statement2 is executed.
After the if-else statement has been executed, control
passes to the next statement. Consider the next code:
if and if-else
Slide 29
If x < y is true, then min is assigned the value of x;
if x < y is false, min is assigned the value of y. After
the if-else statement is executed, min is printed.
if and if-else
Slide 30
The switch Statement
The switch statement is a multiway conditional
statement generalizing the if-else statement. The
general form of the switch statement is given by
Slide 31
The switch Statement
switch (expression)
{
case constant1:
group-of-statements-1;
break;
case constant2:
group-of-statements-2;
break;
.
.
.
default:
default-group-of-statements
}
Slide 32
The switch Statement
Ex:

Weitere ähnliche Inhalte

Was ist angesagt?

Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
Micro Blaze C Reference
Micro Blaze C ReferenceMicro Blaze C Reference
Micro Blaze C Referenceiuui
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++Online
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operatorsAnuja Lad
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzationKaushal Patel
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorseShikshak
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2Pamidimukkala Sivani
 
B sc3 unit 3 boolean algebra
B sc3 unit 3 boolean algebraB sc3 unit 3 boolean algebra
B sc3 unit 3 boolean algebraMahiboobAliMulla
 
Digital logic circuits important question and answers for 5 units
Digital logic circuits important question and answers for 5 unitsDigital logic circuits important question and answers for 5 units
Digital logic circuits important question and answers for 5 unitsLekashri Subramanian
 
simplification of boolean algebra
simplification of boolean algebrasimplification of boolean algebra
simplification of boolean algebramayannpolisticoLNU
 
Benginning Calculus Lecture notes 7 - exp, log
Benginning Calculus Lecture notes 7 - exp, logBenginning Calculus Lecture notes 7 - exp, log
Benginning Calculus Lecture notes 7 - exp, logbasyirstar
 
Benginning Calculus Lecture notes 6 - implicit differentiation
Benginning Calculus Lecture notes 6 - implicit differentiationBenginning Calculus Lecture notes 6 - implicit differentiation
Benginning Calculus Lecture notes 6 - implicit differentiationbasyirstar
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Frankie Jones
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 
Boolean variables r010
Boolean variables   r010Boolean variables   r010
Boolean variables r010arunachalamr16
 

Was ist angesagt? (20)

Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Micro Blaze C Reference
Micro Blaze C ReferenceMicro Blaze C Reference
Micro Blaze C Reference
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Assignment
AssignmentAssignment
Assignment
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
 
Operators and Expressions
Operators and ExpressionsOperators and Expressions
Operators and Expressions
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2
 
B sc3 unit 3 boolean algebra
B sc3 unit 3 boolean algebraB sc3 unit 3 boolean algebra
B sc3 unit 3 boolean algebra
 
C tutorial
C tutorialC tutorial
C tutorial
 
Digital logic circuits important question and answers for 5 units
Digital logic circuits important question and answers for 5 unitsDigital logic circuits important question and answers for 5 units
Digital logic circuits important question and answers for 5 units
 
simplification of boolean algebra
simplification of boolean algebrasimplification of boolean algebra
simplification of boolean algebra
 
Types of Operators in C
Types of Operators in CTypes of Operators in C
Types of Operators in C
 
Benginning Calculus Lecture notes 7 - exp, log
Benginning Calculus Lecture notes 7 - exp, logBenginning Calculus Lecture notes 7 - exp, log
Benginning Calculus Lecture notes 7 - exp, log
 
Benginning Calculus Lecture notes 6 - implicit differentiation
Benginning Calculus Lecture notes 6 - implicit differentiationBenginning Calculus Lecture notes 6 - implicit differentiation
Benginning Calculus Lecture notes 6 - implicit differentiation
 
Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)Chapter 2 Boolean Algebra (part 2)
Chapter 2 Boolean Algebra (part 2)
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
Boolean variables r010
Boolean variables   r010Boolean variables   r010
Boolean variables r010
 

Andere mochten auch

Visual Studio 2008 and .NET 3.5 Overview
Visual Studio 2008 and .NET 3.5 OverviewVisual Studio 2008 and .NET 3.5 Overview
Visual Studio 2008 and .NET 3.5 OverviewDavid Chou
 
Asbestos is to ban
Asbestos is to banAsbestos is to ban
Asbestos is to banJayrin Bae
 
Visual Studio 2008 Overview
Visual Studio 2008 OverviewVisual Studio 2008 Overview
Visual Studio 2008 OverviewRoman Okolovich
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Andrea Francia
 
Intro to visual studio 2008
Intro to visual studio 2008Intro to visual studio 2008
Intro to visual studio 2008nicky_walters
 
Presentation on Visual Studio
Presentation on Visual StudioPresentation on Visual Studio
Presentation on Visual StudioMuhammad Aqeel
 
Introduction to Visual studio 2012
Introduction to Visual studio 2012 Introduction to Visual studio 2012
Introduction to Visual studio 2012 Prashant Chaudhary
 
Visual Basic .NET
Visual Basic .NETVisual Basic .NET
Visual Basic .NETDavid
 
Introduccion a Visual Studio .NET
Introduccion a Visual Studio .NETIntroduccion a Visual Studio .NET
Introduccion a Visual Studio .NETjnarchie
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Salim M
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computersimran153
 

Andere mochten auch (13)

Visual Studio 2008 and .NET 3.5 Overview
Visual Studio 2008 and .NET 3.5 OverviewVisual Studio 2008 and .NET 3.5 Overview
Visual Studio 2008 and .NET 3.5 Overview
 
Asbestos is to ban
Asbestos is to banAsbestos is to ban
Asbestos is to ban
 
Visual Studio 2008 Overview
Visual Studio 2008 OverviewVisual Studio 2008 Overview
Visual Studio 2008 Overview
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008
 
Intro to visual studio 2008
Intro to visual studio 2008Intro to visual studio 2008
Intro to visual studio 2008
 
Presentation on Visual Studio
Presentation on Visual StudioPresentation on Visual Studio
Presentation on Visual Studio
 
Visual Studio IDE
Visual Studio IDEVisual Studio IDE
Visual Studio IDE
 
Introduction to Visual studio 2012
Introduction to Visual studio 2012 Introduction to Visual studio 2012
Introduction to Visual studio 2012
 
Visual Basic .NET
Visual Basic .NETVisual Basic .NET
Visual Basic .NET
 
Introduccion a Visual Studio .NET
Introduccion a Visual Studio .NETIntroduccion a Visual Studio .NET
Introduccion a Visual Studio .NET
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 

Ähnlich wie 2621008 - C++ 2

C programming session 02
C programming session 02C programming session 02
C programming session 02Vivek Singh
 
02 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_0202 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_02Pooja Gupta
 
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Himanshu Kaushik
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsDhivyaSubramaniyam
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7REHAN IJAZ
 
11operator in c#
11operator in c#11operator in c#
11operator in c#Sireesh K
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)SURBHI SAROHA
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptxramanathan2006
 
Constructor and destructors
Constructor and destructorsConstructor and destructors
Constructor and destructorsdivyalakshmi77
 

Ähnlich wie 2621008 - C++ 2 (20)

C programming session 02
C programming session 02C programming session 02
C programming session 02
 
02 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_0202 iec t1_s1_oo_ps_session_02
02 iec t1_s1_oo_ps_session_02
 
Programming C Part 02
Programming C Part 02Programming C Part 02
Programming C Part 02
 
Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++Lecture 2 C++ | Variable Scope, Operators in c++
Lecture 2 C++ | Variable Scope, Operators in c++
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
C operators
C operatorsC operators
C operators
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 
Python Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and FunctionsPython Unit 3 - Control Flow and Functions
Python Unit 3 - Control Flow and Functions
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
11operator in c#
11operator in c#11operator in c#
11operator in c#
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
Computer programming 2 Lesson 7
Computer programming 2  Lesson 7Computer programming 2  Lesson 7
Computer programming 2 Lesson 7
 
Java Programmin: Selections
Java Programmin: SelectionsJava Programmin: Selections
Java Programmin: Selections
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
 
Python : basic operators
Python : basic operatorsPython : basic operators
Python : basic operators
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
C Operators and Control Structures.pptx
C Operators and Control Structures.pptxC Operators and Control Structures.pptx
C Operators and Control Structures.pptx
 
additional.pptx
additional.pptxadditional.pptx
additional.pptx
 
Constructor and destructors
Constructor and destructorsConstructor and destructors
Constructor and destructors
 

Kürzlich hochgeladen

What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreelreely ones
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoUXDXConf
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101vincent683379
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfChristopherTHyatt
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 

Kürzlich hochgeladen (20)

What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 

2621008 - C++ 2

  • 2. Slide 2 Expressions In C++, there are many special characters with particular meanings. Examples include the arithmetic operators: Relational, Equality, and Logical Operators Just as with other operators, the relational, equality, and logical operators have rules of precedence and associativity that determine precisely how expressions involving them are evaluated. C++ systems use the bool values true and false to direct the flow of control in the various statement types.
  • 3. Slide 3 Expressions Relational, Equality, and Logical Operators the relational, equality, and logical operators have rules of precedence and associativity that determine precisely how expressions involving them are evaluated. C++ systems use the bool values true and false to direct the flow of control in the various statement types.
  • 4. Slide 4 Expressions Logical AND (&&) p q p && q T T T F F T F F
  • 5. Slide 5 Expressions Logical AND (&&) p q p && q T T T T F F F T F F F F
  • 6. Slide 6 Expressions Logical OR p q p || q T T T F F T F F
  • 7. Slide 7 Expressions Logical OR p q p || q T T T T F T F T T F F F
  • 10. Bitwise Operators Slide 10 Bitwise operation means convert the number into binary and the carry out the operation on each bit individually. For example let us take the operation complement represented by symbol (~). Let me take a number short A = 42; A short number is stored in two byte or 16 bits. Therefore, A when expressed in binary = 00000000 00101010 Complement of A is ~A = 11111111 11010101 Contd...
  • 12. Slide 12 #include<iostream> using namespace std; void main() { short A =42; short B = 12; int C = A|B; int D = A<<1; cout << "C = "<<C <<endl; cout<< "D = "<<D <<endl; } Bitwise Operators The expected output is as under. C = 46 D = 84
  • 13. Slide 13 #include<iostream> using namespace std; void main() {short A =42; short B = 12; short C = 24; short D = A^B; // XOR operator C <<= 1; A <<=2; // Shift to left by 2 places and assign B >>=2 ; // shift right by 2 places and assign cout<< "A = "<<A<< " tB = "<< B <<endl; cout << "C = "<<C <<endl; cout << "D = "<< D <<endl; } The expected output is given below. A = 168 B = 3 C = 48 D = 38
  • 14. Operators common to C++ Slide 14
  • 15. Slide 15 Operator Precedence In C++, you use operators and expressions such as the following: int MyNumber = 10 * 30 + 20 – 5 * 5 << 2; The question is, what value would MyNumber contain? The order in which the various operators are invoked is very strictly specified by the C++ standard. This order is what is meant by operator precedence.
  • 17. Slide 17 Assignment and Expressions C++ provides assignment operators that combine an assignment operator and some other operator. C++ also provides increment (++) and decrement (--) operators in both prefix and postfix form.
  • 18. Slide 18 Assignment and Expressions The postfix form behaves differently from the prefix form:
  • 19. Slide 19 PROGRAMMING WITH VISUAL C++ C++ Relational, Equality, and Logical
  • 20. Slide 20 PROGRAMMING WITH VISUAL C++ C++ Relational, Equality, and Logical
  • 21. Slide 21 PROGRAMMING WITH VISUAL C++ C++ Relational, Equality, and Logical
  • 22. Slide 22 Statements C++ has a large variety of statement types, including an expression statement. For example, the assignment statement in C++ is syntactically an assignment expression followed by a semicolon. There are two statements: The Simple Statement The Compound Statement
  • 23. Slide 23 The Compound Statement The Compound Statement • A compound statement in C++ is a series of statements surrounded by braces { and }. • The body of a C++ function, for example, is always a compound statement.
  • 24. Conditional ternary operator ( ? ) Slide 24 The conditional operator evaluates an expression, returning first value if that expression evaluates to true, and a different one if the expression evaluates as false. Its syntax is: condition ? result1 : result2 7==5 ? 4 : 3 // evaluates to 3, since 7 is not equal to 5. 7==5+2 ? 4 : 3 // evaluates to 4, since 7 is equal to 5+2. 5>3 ? a : b // evaluates to the value of a, since 5 is greater than 3. a>b ? a : b // evaluates to whichever is greater, a or b.
  • 25. Slide 25 For example: // conditional operator #include <iostream> using namespace std; int main () { int a,b,c; a=2; b=7; c = (a>b) ? a : b; cout << c << 'n'; } In this example, a was 2, and b was 7, so the expression being evaluated (a>b) was not true, thus the first value specified after the question mark was discarded in favor of the second value (the one after the colon) which was b (with a value of 7).
  • 26. Slide 26 The if and if-else Statements if and if-else The general form of an if statement is: Here is an example of an if statement: Or another example:
  • 27. Slide 27 Closely related to the if statement is the if-else statement, which has the general form if and if-else
  • 28. Slide 28 If condition is true, then statement1 is executed and statement2 is skipped; if condition is false, then statement1 is skipped and statement2 is executed. After the if-else statement has been executed, control passes to the next statement. Consider the next code: if and if-else
  • 29. Slide 29 If x < y is true, then min is assigned the value of x; if x < y is false, min is assigned the value of y. After the if-else statement is executed, min is printed. if and if-else
  • 30. Slide 30 The switch Statement The switch statement is a multiway conditional statement generalizing the if-else statement. The general form of the switch statement is given by
  • 31. Slide 31 The switch Statement switch (expression) { case constant1: group-of-statements-1; break; case constant2: group-of-statements-2; break; . . . default: default-group-of-statements }
  • 32. Slide 32 The switch Statement Ex: