SlideShare uma empresa Scribd logo
1 de 16
Increment & Decrement operators (Postfix and Prefix) Ms.Nita Arora KHMS
Increment operator (++) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Increment operator (++) can be used in PREFIX and POSTFIX form. int B=3; int A=++B; //output B=4 //  A=4 int B=3; int A=B++; //output B=4 //  A=3
Decrement operator (--) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Decrement operator (--) can be used in  PREFIX  and  POSTFIX  form. int B=3; int A=--B; //output B=2 //  A=2 int B=3; int A=B- -; //output B=2 //  A=3
Priority of Operators and Associativity Left Comma , 11 Right Assignment = += -= *= /= %= 10 Right Conditional ?: 9 Left Logical  Op. && || 8 Left Relational Op. ==  != 7 Left Relational Op. < <= >= > 6 Left Arithmetic Op. + - 5 Left Arithmetic Op. * / % 4 Right ++ -- ! & * (type) + - 3 Left ()[]->sizeof 2 Left Scope :: 1 associativity Description Operator Priority
Associativity  ,[object Object],[object Object],[object Object]
[object Object],PROBLEM AREA
Examples
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example 1
Example 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example 3
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example 4
6.  What is the screen output?   int  a=20; a += a++  +  ++a ; cout << a; 5.  What is the screen output?    int i, j, k, m, ans;      i = 0;      j = -1;      k = 0;      m = 1;;      ans = i++  &&  ++j   ||  k  ||  m++;      cout<<ans;  4.  What is the screen output?      int i, j, k, ans;      i = 1;      j = 2;      k = 3;      ans = ++i  *   j  -   k--;      cout<<ans; 3.  What is the screen output?      int i, j, k, ans;      i = 1;      j = 2;      k = 3;      ans = i++  *   j  -   --k;      cout<<ans; 2.  What is the screen output?      int a, b;      a = 6;      b = ++a -1;      cout<<&quot;a =  &quot; << a << endl;      cout<<&quot;b =  &quot; << b << endl; 1.  What is the screen output?      int a, b;      a = 6;      b = a++ -1;      cout<<&quot;a =  &quot; << a <<endl;      cout<<&quot;b =  &quot; << b <<endl;  
Evaluate the following c++ expressions where a, b, c are integers and d and f are floating point numbers. The values are a = 5, b=3 and d=1.5 ,[object Object],[object Object],[object Object],[object Object],[object Object]
Do you have any QUESTIONS ?

Mais conteúdo relacionado

Mais procurados

Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 

Mais procurados (20)

2. python basic syntax
2. python   basic syntax2. python   basic syntax
2. python basic syntax
 
Unit 8. Pointers
Unit 8. PointersUnit 8. Pointers
Unit 8. Pointers
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
String in programming language in c or c++
 String in programming language  in c or c++  String in programming language  in c or c++
String in programming language in c or c++
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Type conversions
Type conversionsType conversions
Type conversions
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
 
Double pointer (pointer to pointer)
Double pointer (pointer to pointer)Double pointer (pointer to pointer)
Double pointer (pointer to pointer)
 
Assembler
AssemblerAssembler
Assembler
 
Parsing
ParsingParsing
Parsing
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 

Destaque

Conversion from infix to prefix using stack
Conversion from infix to prefix using stackConversion from infix to prefix using stack
Conversion from infix to prefix using stack
Haqnawaz Ch
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
Ahmed Khateeb
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
mua99
 
Programming methodology lecture01
Programming methodology lecture01Programming methodology lecture01
Programming methodology lecture01
NYversity
 
Programming methodology lecture26
Programming methodology lecture26Programming methodology lecture26
Programming methodology lecture26
NYversity
 

Destaque (20)

Conversion from infix to prefix using stack
Conversion from infix to prefix using stackConversion from infix to prefix using stack
Conversion from infix to prefix using stack
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
 
Infix to postfix
Infix to postfixInfix to postfix
Infix to postfix
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
c programme
c programmec programme
c programme
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversion
 
CHAPTER 3
CHAPTER 3CHAPTER 3
CHAPTER 3
 
Can my English course be translated to Tamil language?
Can my English course be translated to Tamil language?Can my English course be translated to Tamil language?
Can my English course be translated to Tamil language?
 
robotics workshop Aug.09
robotics workshop Aug.09robotics workshop Aug.09
robotics workshop Aug.09
 
Computer Parts
Computer PartsComputer Parts
Computer Parts
 
Programming maintenance - Programming methodology
Programming maintenance - Programming methodologyProgramming maintenance - Programming methodology
Programming maintenance - Programming methodology
 
A message of stephen covey
A message of stephen coveyA message of stephen covey
A message of stephen covey
 
Butterfly
ButterflyButterfly
Butterfly
 
Programming methodology lecture01
Programming methodology lecture01Programming methodology lecture01
Programming methodology lecture01
 
Edge2008
Edge2008Edge2008
Edge2008
 
Think It
Think ItThink It
Think It
 
Robot Timeline
Robot TimelineRobot Timeline
Robot Timeline
 
Programming methodology lecture26
Programming methodology lecture26Programming methodology lecture26
Programming methodology lecture26
 

Semelhante a Prefix Postfix

Cplusplus
CplusplusCplusplus
Cplusplus
dancey
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
alish sha
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
alish sha
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
alish sha
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
勇浩 赖
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ Advanced
Vivek Das
 

Semelhante a Prefix Postfix (20)

Lab # 2
Lab # 2Lab # 2
Lab # 2
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Cplusplus
CplusplusCplusplus
Cplusplus
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
 
About Go
About GoAbout Go
About Go
 
C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh C - programming - Ankit Kumar Singh
C - programming - Ankit Kumar Singh
 
C Operators
C OperatorsC Operators
C Operators
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Arduino programming of ML-style in ATS
Arduino programming of ML-style in ATSArduino programming of ML-style in ATS
Arduino programming of ML-style in ATS
 
Ponters
PontersPonters
Ponters
 
Ponters
PontersPonters
Ponters
 
901131 examples
901131 examples901131 examples
901131 examples
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators
OperatorsOperators
Operators
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ Advanced
 

Mais de Kulachi Hansraj Model School Ashok Vihar (14)

Edge 2010
Edge 2010Edge 2010
Edge 2010
 
Story 1
Story 1Story 1
Story 1
 
Stack Applications
Stack ApplicationsStack Applications
Stack Applications
 
Loops
LoopsLoops
Loops
 
Computer System Organization
Computer System OrganizationComputer System Organization
Computer System Organization
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
Tut Constructor
Tut ConstructorTut Constructor
Tut Constructor
 
Programming Methodology
Programming MethodologyProgramming Methodology
Programming Methodology
 
Arrays
ArraysArrays
Arrays
 
Looping
LoopingLooping
Looping
 
Computer Fundamentals
Computer FundamentalsComputer Fundamentals
Computer Fundamentals
 
Number System
Number SystemNumber System
Number System
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
File Pointers
File PointersFile Pointers
File Pointers
 

Último

Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
dlhescort
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
dollysharma2066
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
lizamodels9
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Sheetaleventcompany
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
dlhescort
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
amitlee9823
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
amitlee9823
 

Último (20)

It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors Data
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hebbal Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
Call Girls Jp Nagar Just Call 👗 7737669865 👗 Top Class Call Girl Service Bang...
 

Prefix Postfix

  • 1. Increment & Decrement operators (Postfix and Prefix) Ms.Nita Arora KHMS
  • 2.
  • 3. Increment operator (++) can be used in PREFIX and POSTFIX form. int B=3; int A=++B; //output B=4 // A=4 int B=3; int A=B++; //output B=4 // A=3
  • 4.
  • 5. Decrement operator (--) can be used in PREFIX and POSTFIX form. int B=3; int A=--B; //output B=2 // A=2 int B=3; int A=B- -; //output B=2 // A=3
  • 6. Priority of Operators and Associativity Left Comma , 11 Right Assignment = += -= *= /= %= 10 Right Conditional ?: 9 Left Logical Op. && || 8 Left Relational Op. == != 7 Left Relational Op. < <= >= > 6 Left Arithmetic Op. + - 5 Left Arithmetic Op. * / % 4 Right ++ -- ! & * (type) + - 3 Left ()[]->sizeof 2 Left Scope :: 1 associativity Description Operator Priority
  • 7.
  • 8.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. 6.  What is the screen output? int a=20; a += a++ + ++a ; cout << a; 5.  What is the screen output?    int i, j, k, m, ans;      i = 0;      j = -1;      k = 0;      m = 1;;      ans = i++  &&  ++j   ||  k  ||  m++;      cout<<ans; 4.  What is the screen output?      int i, j, k, ans;      i = 1;      j = 2;      k = 3;      ans = ++i  *   j  -   k--;      cout<<ans; 3.  What is the screen output?      int i, j, k, ans;      i = 1;      j = 2;      k = 3;      ans = i++  *   j  -   --k;      cout<<ans; 2.  What is the screen output?      int a, b;      a = 6;      b = ++a -1;      cout<<&quot;a =  &quot; << a << endl;      cout<<&quot;b =  &quot; << b << endl; 1.  What is the screen output?      int a, b;      a = 6;      b = a++ -1;      cout<<&quot;a =  &quot; << a <<endl;      cout<<&quot;b =  &quot; << b <<endl;  
  • 15.
  • 16. Do you have any QUESTIONS ?

Notas do Editor

  1. 1 1 The “operator” keyword Overloading Unary operators Overloading Binary operators Constructors as conversion routines Converting between basic and user-defined types LEAD IN: Overloaded Unary Operators