SlideShare a Scribd company logo
Centre for Artificial Intelligence
Madhav Institute of Technology & Science
Submitted to : Submitted by:
Mr. Arun Kumar Yash Jain(0901AI231077)
Promblem Solving
and Programming
<OPERATORS>
{
}
...
OPERATORS
The symbol that are used in C++ programs to form
an expression are known as OPERATORS.C++ has a
rich set of operators including all C language’s
operators and also some new operators. There are
three categories of operators in C++.
These are :
01: Unary Operators
02: Binary Operators
03: Ternary Operators
OPERATORS
The operators thatr operate a single
operand to form an expression are
Unary operators.like ++,--
The operators that operate two or
more operands are Binary operators.
The operators are +,-,*,/,% etc.
The operators that operates minimum or maximum
three operands are Ternary operators. Only one
(?) used as substitute of if-else statement.
01
02
03
Unary Operators
Binary Operators
Ternary Operators
Type of
operators in
C++
< * Arithmetic Operators
* Logical Operators
* Bitwise Operators
* Relational Operators
* Assignment Operators >
}
The operators that helps the programmer in
mathematical calculation are Arithmetic Operators.
Its include (+) for addition , (-) for
subtraction, (/) for division ,(*) for
multiplication etc.
01.Arthimetic Operators
<example>
2+5= 7
2*7= 14
8/2= 4
8-4= 4
} ..
Program for arthimetic operators
OUTPUT:
Sum: 15
Difference: 5
Product: 50
Quotient: 2
Remainder: 0
#include <iostream>
using namespace std;
int main() {
int num1 = 10, num2 = 5;
int sum = num1 + num2;
cout << "Sum: " << sum << endl;
int difference = num1 - num2;
cout << "Difference: " << difference << endl;
int product = num1 * num2;
cout << "Product: " << product << endl;
int quotient = num1 / num2;
cout << "Quotient: " << quotient << endl;
int remainder = num1 % num2;
cout << "Remainder: " << remainder << endl;
return 0;
}
} ..
02.Logical Operators
The Operators that help the
programmer to connect (combine)
two or more expression, are
known as Logical Operators.
It include :
01: (&&) logical AND
02: (||) logical OR
03: (!) logical NOT
Program for logical operators
OUTPUT;
x && y: 0
x && z: 1
x || y: 1
y || z: 1
!x: 0
!y: 1
#include <iostream>
using namespace std;
int main() {
bool x = true, y = false, z = true;
// AND operator (&&)
cout << "x && y: " << (x && y) << endl; // false
cout << "x && z: " << (x && z) << endl; // true
// OR operator (||)
cout << "x || y: " << (x || y) << endl; // true
cout << "y || z: " << (y || z) << endl; // true
// NOT operator (!)
cout << "!x: " << !x << endl; // false
cout << "!y: " << !y << endl; // true
return 0;
}
{
}
03.Bitwise Operators
(~) bitwise complement
(<<) left shift
(>>) right shift
(&) bitwise AND
(|) bitwise OR
(^) bitwise exclusive Or
The operators which operate a bit level and
allows the programmer to manipulate
individual bits. These are basically used
for testing or shifting bits.
Bitwise operators are:
Program for Bitwise operators
#include <iostream>
using namespace std;
int main(){
int x = 10, y = 7, z = 0;
// Bitwise AND (&)
z = x & y;
cout << "x & y = " << z << endl;
// Bitwise OR (|)
z = x | y;
cout << "x | y = " << z << endl;
// Bitwise XOR (^)
z = x ^ y;
cout << "x ^ y = " << z << endl;
// Bitwise NOT (~)
z = ~x;
cout << "~x = " << z << endl;
// Left shift (<<)
z = x << 2;
cout << "x << 2 = " << z << endl;
// Right shift (>>)
z = y >> 1;
cout << "y >> 1 = " << z << endl;
return 0;
}
OUYPUT:
x & y = 2
x | y = 15
x ^ y = 13
~x = -11
x << 2 = 40
y >> 1 = 3
04.Relational Operators
Relational operators are used to
compare values and determine their
relationship. They return a Boolean
value of TRUE(1) if the relation is
true, and false(0) if it’s not.
X == y
equal to
==
X != y
Not equal to
!=
X > y
Greater than
>
X < y
Less than
<
X >= y
Greater than or equal to
>=
X <= y
Less than or equal to
<=
Program for relational operators
int num1 = 20, num2 = 15;
// Equality check
if (num1 == num2) {
cout << num1 << " is equal to " << num2 << endl;
} else {
cout << num1 << " is not equal to " << num2 << endl;
}
// Greater than check
if (num1 > num2) {
cout << num1 << " is greater than " << num2 << endl;
}
// Less than check
if (num1 < num2) {
cout << num1 << " is less than " << num2 << endl;
}
// Greater than or equal to check
if (num1 >= num2) {
cout << num1 << " is greater than or equal to " << num2 << endl;
}
// Less than or equal to check
if (num1 <= num2) {
cout << num1 << " is less than or equal to " << num2 << endl;
}
}..
OUTPUT:
20 is not equal to 15
20 is greater than 15
20 is greater than or
equal to 15
05.Assignment Operators
{
} ..
Assignment operators are used to assign values to
variables. They store the value on the right side
of the operator into the variable on the left
side.it include :
01. Simple assign (=)
02. Add and assign (+=)
03. Subtract and assign (-=)
04. Multiply and assign (*=)
05. Divide and assign (/=)
06. Modulo assign (%=)
Program for Assignment operators
int x = 10;
int y = 5;
// Simple assignment
cout << "Original value of x: " << x << endl;
x = 20; // Assign 20 to x
cout << "After assignment: x = " << x << endl;
// Compound assignment operators
x += 5; // Equivalent to x = x + 5
cout << "After x += 5: x = " << x << endl;
y -= 2; // Equivalent to y = y - 2
cout << "After y -= 2: y = " << y << endl;
x *= 3; // Equivalent to x = x * 3
cout << "After x *= 3: x = " << x << endl;
y /= 2; // Equivalent to y = y / 2
cout << "After y /= 2: y = " << y << endl;
return 0;
}
OUTPUT:
Original value of x: 10
After assignment: x = 20
After x += 5:
x = 25
After y -= 2:
y = 3
After x *= 3:
x = 75
After y /= 2:
y = 1
{
} ..
..

More Related Content

Similar to power point presentation on topic in C++ called "OPERATORS"

Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statementsCtOlaf
 
Operators
OperatorsOperators
Operators
Kamran
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
sunny khan
 
This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
ranaashutosh531pvt
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
ruchisuru20001
 
Operators in java
Operators in javaOperators in java
Operators in java
yugandhar vadlamudi
 
5_Operators.pdf
5_Operators.pdf5_Operators.pdf
5_Operators.pdf
NiraliArora2
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)jahanullah
 
C++ chapter 2
C++ chapter 2C++ chapter 2
C++ chapter 2
SHRIRANG PINJARKAR
 
Types of Operators in C programming .pdf
Types of Operators in C programming  .pdfTypes of Operators in C programming  .pdf
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
Anusuya123
 
Theory3
Theory3Theory3
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3sotlsoc
 
Operators in C++.pptx
Operators in C++.pptxOperators in C++.pptx
Operators in C++.pptx
ssuser41748c
 
Class 2 variables, classes methods...
Class 2   variables, classes methods...Class 2   variables, classes methods...
Class 2 variables, classes methods...
Fernando Loizides
 
C operators ppt
C operators pptC operators ppt
C operators ppt
RajniKashyap9
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
Praveen M Jigajinni
 

Similar to power point presentation on topic in C++ called "OPERATORS" (20)

Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
Operators
OperatorsOperators
Operators
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
 
operators.pptx
operators.pptxoperators.pptx
operators.pptx
 
Operators in java
Operators in javaOperators in java
Operators in java
 
5_Operators.pdf
5_Operators.pdf5_Operators.pdf
5_Operators.pdf
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
C Sharp Jn (2)
C Sharp Jn (2)C Sharp Jn (2)
C Sharp Jn (2)
 
C++ chapter 2
C++ chapter 2C++ chapter 2
C++ chapter 2
 
Types of Operators in C programming .pdf
Types of Operators in C programming  .pdfTypes of Operators in C programming  .pdf
Types of Operators in C programming .pdf
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Theory3
Theory3Theory3
Theory3
 
Operators
OperatorsOperators
Operators
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
Operators in C++.pptx
Operators in C++.pptxOperators in C++.pptx
Operators in C++.pptx
 
Class 2 variables, classes methods...
Class 2   variables, classes methods...Class 2   variables, classes methods...
Class 2 variables, classes methods...
 
C operators ppt
C operators pptC operators ppt
C operators ppt
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 

Recently uploaded

PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Ethernet Routing and switching chapter 1.ppt
Ethernet Routing and switching chapter 1.pptEthernet Routing and switching chapter 1.ppt
Ethernet Routing and switching chapter 1.ppt
azkamurat
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 

Recently uploaded (20)

PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Ethernet Routing and switching chapter 1.ppt
Ethernet Routing and switching chapter 1.pptEthernet Routing and switching chapter 1.ppt
Ethernet Routing and switching chapter 1.ppt
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 

power point presentation on topic in C++ called "OPERATORS"

  • 1. Centre for Artificial Intelligence Madhav Institute of Technology & Science Submitted to : Submitted by: Mr. Arun Kumar Yash Jain(0901AI231077)
  • 3. OPERATORS The symbol that are used in C++ programs to form an expression are known as OPERATORS.C++ has a rich set of operators including all C language’s operators and also some new operators. There are three categories of operators in C++. These are : 01: Unary Operators 02: Binary Operators 03: Ternary Operators
  • 4. OPERATORS The operators thatr operate a single operand to form an expression are Unary operators.like ++,-- The operators that operate two or more operands are Binary operators. The operators are +,-,*,/,% etc. The operators that operates minimum or maximum three operands are Ternary operators. Only one (?) used as substitute of if-else statement. 01 02 03 Unary Operators Binary Operators Ternary Operators
  • 5. Type of operators in C++ < * Arithmetic Operators * Logical Operators * Bitwise Operators * Relational Operators * Assignment Operators > }
  • 6. The operators that helps the programmer in mathematical calculation are Arithmetic Operators. Its include (+) for addition , (-) for subtraction, (/) for division ,(*) for multiplication etc. 01.Arthimetic Operators <example> 2+5= 7 2*7= 14 8/2= 4 8-4= 4 } ..
  • 7. Program for arthimetic operators OUTPUT: Sum: 15 Difference: 5 Product: 50 Quotient: 2 Remainder: 0 #include <iostream> using namespace std; int main() { int num1 = 10, num2 = 5; int sum = num1 + num2; cout << "Sum: " << sum << endl; int difference = num1 - num2; cout << "Difference: " << difference << endl; int product = num1 * num2; cout << "Product: " << product << endl; int quotient = num1 / num2; cout << "Quotient: " << quotient << endl; int remainder = num1 % num2; cout << "Remainder: " << remainder << endl; return 0; } } ..
  • 8. 02.Logical Operators The Operators that help the programmer to connect (combine) two or more expression, are known as Logical Operators. It include : 01: (&&) logical AND 02: (||) logical OR 03: (!) logical NOT
  • 9. Program for logical operators OUTPUT; x && y: 0 x && z: 1 x || y: 1 y || z: 1 !x: 0 !y: 1 #include <iostream> using namespace std; int main() { bool x = true, y = false, z = true; // AND operator (&&) cout << "x && y: " << (x && y) << endl; // false cout << "x && z: " << (x && z) << endl; // true // OR operator (||) cout << "x || y: " << (x || y) << endl; // true cout << "y || z: " << (y || z) << endl; // true // NOT operator (!) cout << "!x: " << !x << endl; // false cout << "!y: " << !y << endl; // true return 0; } { }
  • 10. 03.Bitwise Operators (~) bitwise complement (<<) left shift (>>) right shift (&) bitwise AND (|) bitwise OR (^) bitwise exclusive Or The operators which operate a bit level and allows the programmer to manipulate individual bits. These are basically used for testing or shifting bits. Bitwise operators are:
  • 11. Program for Bitwise operators #include <iostream> using namespace std; int main(){ int x = 10, y = 7, z = 0; // Bitwise AND (&) z = x & y; cout << "x & y = " << z << endl; // Bitwise OR (|) z = x | y; cout << "x | y = " << z << endl; // Bitwise XOR (^) z = x ^ y; cout << "x ^ y = " << z << endl; // Bitwise NOT (~) z = ~x; cout << "~x = " << z << endl; // Left shift (<<) z = x << 2; cout << "x << 2 = " << z << endl; // Right shift (>>) z = y >> 1; cout << "y >> 1 = " << z << endl; return 0; } OUYPUT: x & y = 2 x | y = 15 x ^ y = 13 ~x = -11 x << 2 = 40 y >> 1 = 3
  • 12. 04.Relational Operators Relational operators are used to compare values and determine their relationship. They return a Boolean value of TRUE(1) if the relation is true, and false(0) if it’s not. X == y equal to == X != y Not equal to != X > y Greater than > X < y Less than < X >= y Greater than or equal to >= X <= y Less than or equal to <=
  • 13. Program for relational operators int num1 = 20, num2 = 15; // Equality check if (num1 == num2) { cout << num1 << " is equal to " << num2 << endl; } else { cout << num1 << " is not equal to " << num2 << endl; } // Greater than check if (num1 > num2) { cout << num1 << " is greater than " << num2 << endl; } // Less than check if (num1 < num2) { cout << num1 << " is less than " << num2 << endl; } // Greater than or equal to check if (num1 >= num2) { cout << num1 << " is greater than or equal to " << num2 << endl; } // Less than or equal to check if (num1 <= num2) { cout << num1 << " is less than or equal to " << num2 << endl; } }.. OUTPUT: 20 is not equal to 15 20 is greater than 15 20 is greater than or equal to 15
  • 14. 05.Assignment Operators { } .. Assignment operators are used to assign values to variables. They store the value on the right side of the operator into the variable on the left side.it include : 01. Simple assign (=) 02. Add and assign (+=) 03. Subtract and assign (-=) 04. Multiply and assign (*=) 05. Divide and assign (/=) 06. Modulo assign (%=)
  • 15. Program for Assignment operators int x = 10; int y = 5; // Simple assignment cout << "Original value of x: " << x << endl; x = 20; // Assign 20 to x cout << "After assignment: x = " << x << endl; // Compound assignment operators x += 5; // Equivalent to x = x + 5 cout << "After x += 5: x = " << x << endl; y -= 2; // Equivalent to y = y - 2 cout << "After y -= 2: y = " << y << endl; x *= 3; // Equivalent to x = x * 3 cout << "After x *= 3: x = " << x << endl; y /= 2; // Equivalent to y = y / 2 cout << "After y /= 2: y = " << y << endl; return 0; } OUTPUT: Original value of x: 10 After assignment: x = 20 After x += 5: x = 25 After y -= 2: y = 3 After x *= 3: x = 75 After y /= 2: y = 1