SlideShare a Scribd company logo
Computer
Programming in C
Input-Output
Instructions in C
By : Rahul Sharma
Subscribe channel on YouTube
Follow us on Facebook
Input-Output
Instruction in C
Subscribe our YouTube channel
Follow us on Facebook
Operators
Example: 5 + 6
Operator
Operands
Operators
5 * 5 + 3
28 40
BODMAS Rule is not apply in C language.
Bitwise Operators
❑ There are six types of bitwise operators
➢ Bitwise ‘AND’ (&)
➢ Bitwise ‘OR’ (|)
➢ Bitwise ‘XOR’ or Exclusive OR (^)
➢ Bitwise ‘NOT’ (~)
➢ Right Shift (>>)
➢ Left Shift (<<)
Unary Operators
❑ +, - , ++, --, sizeof( ).
❑ Unary operators are operators those required only one
operand to perform operations.
Unary Operators
➢ -a, -b, -c; Negative
➢ +a, +b, +c ; Positive
➢ --a, --b,--c; Decrement Operator
➢ ++a,++b,++c : Increment Operator
Unary Operator: Use will only 1
operand
Binary Operator: Use will only 2 operand
Ternary Operator: Use will only 3
operand
Unary Operators
➢ ++(Increment Operator)
• Post Increment Operator(x++)
• Pre Increment Operator(++x)
➢ --(Decrement Operator)
• Post Decrement Operator(x--)
• Pre Decrement Operator(--x)
Bitwise Operators
➢ Bitwise AND (&)
➢ Bitwise OR ( | )
➢ Bitwise XOR or Exclusive OR (^)
➢ Bitwise NOT ~
➢ Bitwise Right shift >>
➢ Bitwise Left shift <<
Bitwise Operators
Bitwise AND(&) : This operator work on binary numbers .
Operand Operator Operand Output
0 & 0 0
0 & 1 0
1 & 0 0
1 & 1 1
Ex:
Int x;
X= 23 & 56;
56 = 0000 0000 0011 1000
23= 0000 0000 0001 0111
16 = 0000 0000 0001 0000
16
2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
9 8 7 6 5 4 3 2 1 0
If Both true then
O/P will be true
Bitwise Operators
Bitwise OR(|) : This operator work on binary numbers .
Operand Operator Operand Output
0 | 0 0
0 | 1 1
1 | 0 1
1 | 1 1
Ex:
Int x;
X= 23 & 56
56 = 0000 0000 0011 1000
23 = 0000 0000 0001 0111
63 = 0000 0000 0011 1111
1+2+4+8+16+32=
63
2^9 2^
8
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
9 8 7 6 5 4 3 2 1 0
If one value is
true then O/P will
be true.
Bitwise Operators
Bitwise XOR(^) : This operator work on binary numbers . If Both
operands are same than output will be 0 if different then 1.
Operand Operator Operand Output
0 ^ 0 0
0 ^ 1 1
1 ^ 0 1
1 ^ 1 0
Ex:
Int x;
X= 23 & 56
56 = 0000 0000 0011 1000
23 = 0000 0000 0001 0111
= 0000 0000 0010 1111
1+2+4+8+32=47
2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
9 8 7 6 5 4 3 2 1 0
Both should be
different to get
true value.
Bitwise Operators
Bitwise Right shift (>>) : This operator work on binary numbers .
Here we have to add 00 in left side
Ex:
Int x;
X= 56>>2
56 = 0000 0000 0011 1000
Step 1: = 0000 0000 0000 1110 00
2+4+8=14
2^9 2^8 2^7 2^6 2^
5
2^4 2^3 2^2 2^1 2^0
9 8 7 6 5 4 3 2 1 0
Bitwise Operators
Bitwise Left shift (<<) : This operator work on binary numbers .
Here we have to add 00 in right side
Ex:
Int x;
X= 56<<2
56 = 0000 0000 0011 1000
Step 1: 56 = 00 0000 0000 1110 0000
32+64+128=448
2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
9 8 7 6 5 4 3 2 1 0
Relational Operators
➢ <, >, <=,>= ( 1 )
➢ ==, != ( 2)
➢ Here priority of set-1 is greater than set-2.
➢ Relational Operators always Yields results either 0 or 1.
➢ Every Non-zero value is true and zero value is false
main()
{ int x;
clrscr();
x = 3>4;
printf(“%d”, x);
}
0
Ctrl+F9
Output :
Logical Operators
➢ NOT !
➢ And &&
➢ OR ||
❖ NOT !
▪ This an unary operator.
▪ Priority level is also same as unary operator.
▪ It inverts the truth value of statement .
▪ !T = F
▪ !F = T
Logical Operators
❖ NOT !
▪ This an unary operator.
▪ Priority level is also same as unary operator.
▪ It inverts the truth value of statement .
▪ !T = F
▪ !F = T
Logical Operators
❖ NOT !
▪ This an unary operator.
▪ Example:
main()
{ int x=5;
clrscr();
x = !x > 4; // 0>4==0
printf(“%d”, x);
}
0
Ctrl+F9
Output :
Logical Operators
❖ AND &&
▪ This an Binary operator.
▪ If both operand are non zero(true) then it becomes true.
Operand Operator Operand Output
F && F F
T && F F
T && F F
T && T T
Logical Operators
❖ AND &&
▪ This an Binary operator.
▪ Example: main()
{ int x=5, y;
clrscr();
y = x > 4 && x <10 ; // T && T==1
printf(“%d”, y);
}
1
Ctrl+F9
Output :
Logical Operators
❖ OR ||
▪ This an Binary operator.
▪ If any of the two operands is non-zero(true) then it becomes true.
Operand Operator Operand Output
F || F F
T || F T
T || F T
T || T T
Thank You
➢ For Detailed understanding,
Subscribe our channel on
You tube.
➢ Follow us on Facebook
✓ Page name : Digital Wave (
Link in Description Box)

More Related Content

What's hot (19)

PPTX
Operators in C/C++
Shobi P P
 
PPTX
C OPERATOR
rricky98
 
PDF
The Ring programming language version 1.6 book - Part 21 of 189
Mahmoud Samir Fayed
 
PPTX
Operator in c programming
Manoj Tyagi
 
PPT
Basic c operators
Anuja Lad
 
PPTX
Stack1
Iqrazb
 
PPTX
Expression and Operartor In C Programming
Kamal Acharya
 
PPTX
Operator of C language
Kritika Chauhan
 
PDF
Python Basic Operators
Soba Arjun
 
PPT
C Sharp Jn (2)
guest58c84c
 
PPTX
Functions
wilde1kd
 
PDF
2 2. operators
웅식 전
 
PPTX
C Programming Language Part 4
Rumman Ansari
 
PPTX
Working with IDE
Nurul Zakiah Zamri Tan
 
PDF
175035-cse LAB-04
Mahbubay Rabbani Mim
 
DOCX
Faisal
Faisal Saeed
 
DOCX
Newton cotes method
Faisal Saeed
 
Operators in C/C++
Shobi P P
 
C OPERATOR
rricky98
 
The Ring programming language version 1.6 book - Part 21 of 189
Mahmoud Samir Fayed
 
Operator in c programming
Manoj Tyagi
 
Basic c operators
Anuja Lad
 
Stack1
Iqrazb
 
Expression and Operartor In C Programming
Kamal Acharya
 
Operator of C language
Kritika Chauhan
 
Python Basic Operators
Soba Arjun
 
C Sharp Jn (2)
guest58c84c
 
Functions
wilde1kd
 
2 2. operators
웅식 전
 
C Programming Language Part 4
Rumman Ansari
 
Working with IDE
Nurul Zakiah Zamri Tan
 
175035-cse LAB-04
Mahbubay Rabbani Mim
 
Faisal
Faisal Saeed
 
Newton cotes method
Faisal Saeed
 

Similar to 4. operators in c programming by digital wave (20)

PPTX
C operators
AbiramiT9
 
PPTX
C operators
Rupanshi rawat
 
PPTX
Operators and expressions in c language
tanmaymodi4
 
PPTX
Operators inc c language
Tanmay Modi
 
ODP
Operators
jayesh30sikchi
 
PPTX
OPERATORS OF C++
ANANT VYAS
 
PPTX
Operators and it's type
Asheesh kushwaha
 
PDF
Types of Operators in C
Thesis Scientist Private Limited
 
PPT
6 operators-in-c
Rohit Shrivastava
 
PPTX
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
PPTX
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Orin18
 
PPTX
PROGRAMMING IN C - Operators.pptx
Nithya K
 
DOCX
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
Sitamarhi Institute of Technology
 
PPTX
Unit 4. Operators and Expression
Ashim Lamichhane
 
PDF
C Operators and Control Structures.pdf
MaryJacob24
 
PDF
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
DOC
Report on c
jasmeen kr
 
PPTX
C Operators and Control Structures.pptx
ramanathan2006
 
PDF
introduction to c programming - Topic 3.pdf
rajd20284
 
PPTX
Operators in C & C++ Language
PreSolutions Softwares
 
C operators
AbiramiT9
 
C operators
Rupanshi rawat
 
Operators and expressions in c language
tanmaymodi4
 
Operators inc c language
Tanmay Modi
 
Operators
jayesh30sikchi
 
OPERATORS OF C++
ANANT VYAS
 
Operators and it's type
Asheesh kushwaha
 
Types of Operators in C
Thesis Scientist Private Limited
 
6 operators-in-c
Rohit Shrivastava
 
C - programming - Ankit Kumar Singh
AnkitSinghRajput35
 
btwggggggggggggggggggggggggggggggisop correct (1).pptx
Orin18
 
PROGRAMMING IN C - Operators.pptx
Nithya K
 
PPS 2.2.OPERATORS ARITHMETIC EXPRESSIONS/ARITHMETIC OPERATORS/RELATIONAL OPER...
Sitamarhi Institute of Technology
 
Unit 4. Operators and Expression
Ashim Lamichhane
 
C Operators and Control Structures.pdf
MaryJacob24
 
Unit ii chapter 1 operator and expressions in c
Sowmya Jyothi
 
Report on c
jasmeen kr
 
C Operators and Control Structures.pptx
ramanathan2006
 
introduction to c programming - Topic 3.pdf
rajd20284
 
Operators in C & C++ Language
PreSolutions Softwares
 
Ad

Recently uploaded (20)

PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Ad

4. operators in c programming by digital wave

  • 1. Computer Programming in C Input-Output Instructions in C By : Rahul Sharma Subscribe channel on YouTube Follow us on Facebook
  • 2. Input-Output Instruction in C Subscribe our YouTube channel Follow us on Facebook
  • 3. Operators Example: 5 + 6 Operator Operands
  • 4. Operators 5 * 5 + 3 28 40 BODMAS Rule is not apply in C language.
  • 5. Bitwise Operators ❑ There are six types of bitwise operators ➢ Bitwise ‘AND’ (&) ➢ Bitwise ‘OR’ (|) ➢ Bitwise ‘XOR’ or Exclusive OR (^) ➢ Bitwise ‘NOT’ (~) ➢ Right Shift (>>) ➢ Left Shift (<<)
  • 6. Unary Operators ❑ +, - , ++, --, sizeof( ). ❑ Unary operators are operators those required only one operand to perform operations.
  • 7. Unary Operators ➢ -a, -b, -c; Negative ➢ +a, +b, +c ; Positive ➢ --a, --b,--c; Decrement Operator ➢ ++a,++b,++c : Increment Operator Unary Operator: Use will only 1 operand Binary Operator: Use will only 2 operand Ternary Operator: Use will only 3 operand
  • 8. Unary Operators ➢ ++(Increment Operator) • Post Increment Operator(x++) • Pre Increment Operator(++x) ➢ --(Decrement Operator) • Post Decrement Operator(x--) • Pre Decrement Operator(--x)
  • 9. Bitwise Operators ➢ Bitwise AND (&) ➢ Bitwise OR ( | ) ➢ Bitwise XOR or Exclusive OR (^) ➢ Bitwise NOT ~ ➢ Bitwise Right shift >> ➢ Bitwise Left shift <<
  • 10. Bitwise Operators Bitwise AND(&) : This operator work on binary numbers . Operand Operator Operand Output 0 & 0 0 0 & 1 0 1 & 0 0 1 & 1 1 Ex: Int x; X= 23 & 56; 56 = 0000 0000 0011 1000 23= 0000 0000 0001 0111 16 = 0000 0000 0001 0000 16 2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 9 8 7 6 5 4 3 2 1 0 If Both true then O/P will be true
  • 11. Bitwise Operators Bitwise OR(|) : This operator work on binary numbers . Operand Operator Operand Output 0 | 0 0 0 | 1 1 1 | 0 1 1 | 1 1 Ex: Int x; X= 23 & 56 56 = 0000 0000 0011 1000 23 = 0000 0000 0001 0111 63 = 0000 0000 0011 1111 1+2+4+8+16+32= 63 2^9 2^ 8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 9 8 7 6 5 4 3 2 1 0 If one value is true then O/P will be true.
  • 12. Bitwise Operators Bitwise XOR(^) : This operator work on binary numbers . If Both operands are same than output will be 0 if different then 1. Operand Operator Operand Output 0 ^ 0 0 0 ^ 1 1 1 ^ 0 1 1 ^ 1 0 Ex: Int x; X= 23 & 56 56 = 0000 0000 0011 1000 23 = 0000 0000 0001 0111 = 0000 0000 0010 1111 1+2+4+8+32=47 2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 9 8 7 6 5 4 3 2 1 0 Both should be different to get true value.
  • 13. Bitwise Operators Bitwise Right shift (>>) : This operator work on binary numbers . Here we have to add 00 in left side Ex: Int x; X= 56>>2 56 = 0000 0000 0011 1000 Step 1: = 0000 0000 0000 1110 00 2+4+8=14 2^9 2^8 2^7 2^6 2^ 5 2^4 2^3 2^2 2^1 2^0 9 8 7 6 5 4 3 2 1 0
  • 14. Bitwise Operators Bitwise Left shift (<<) : This operator work on binary numbers . Here we have to add 00 in right side Ex: Int x; X= 56<<2 56 = 0000 0000 0011 1000 Step 1: 56 = 00 0000 0000 1110 0000 32+64+128=448 2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 9 8 7 6 5 4 3 2 1 0
  • 15. Relational Operators ➢ <, >, <=,>= ( 1 ) ➢ ==, != ( 2) ➢ Here priority of set-1 is greater than set-2. ➢ Relational Operators always Yields results either 0 or 1. ➢ Every Non-zero value is true and zero value is false main() { int x; clrscr(); x = 3>4; printf(“%d”, x); } 0 Ctrl+F9 Output :
  • 16. Logical Operators ➢ NOT ! ➢ And && ➢ OR || ❖ NOT ! ▪ This an unary operator. ▪ Priority level is also same as unary operator. ▪ It inverts the truth value of statement . ▪ !T = F ▪ !F = T
  • 17. Logical Operators ❖ NOT ! ▪ This an unary operator. ▪ Priority level is also same as unary operator. ▪ It inverts the truth value of statement . ▪ !T = F ▪ !F = T
  • 18. Logical Operators ❖ NOT ! ▪ This an unary operator. ▪ Example: main() { int x=5; clrscr(); x = !x > 4; // 0>4==0 printf(“%d”, x); } 0 Ctrl+F9 Output :
  • 19. Logical Operators ❖ AND && ▪ This an Binary operator. ▪ If both operand are non zero(true) then it becomes true. Operand Operator Operand Output F && F F T && F F T && F F T && T T
  • 20. Logical Operators ❖ AND && ▪ This an Binary operator. ▪ Example: main() { int x=5, y; clrscr(); y = x > 4 && x <10 ; // T && T==1 printf(“%d”, y); } 1 Ctrl+F9 Output :
  • 21. Logical Operators ❖ OR || ▪ This an Binary operator. ▪ If any of the two operands is non-zero(true) then it becomes true. Operand Operator Operand Output F || F F T || F T T || F T T || T T
  • 22. Thank You ➢ For Detailed understanding, Subscribe our channel on You tube. ➢ Follow us on Facebook ✓ Page name : Digital Wave ( Link in Description Box)