SlideShare a Scribd company logo
What is difference between Prefix & Postfix
(++i ,--i & i++ , i--)
So what is the difference????
Prefix Postfix
The ++ or -- symbol is
used before the variable.
The ++ or -- symbol is used
after the variable.
Example: ++i or --i Exmple i++ or i--
It means : i= i+1 or It means: i= i+1 or
i= i-1 i= i-1
It will be easy for u to understand these if u keep two things in
ur mind. That is :
In prefix : First increment / decrement by 1 then assign .
In postfix: First assign then increment/ decrement by 1 .
In prefix:
int i =5;
++i;
Output: 6
It works like:
i = ++i ; // First increment
= i+1;
= 5+1;
= 6;
int i = 6; // Then assign
Note:
In program the last & final value is accepted.
In postfix:
int i =5;
i++;
Output: 6
It works like:
int i = 5; // First assign
i =i++; // Then increment
= i+1;
= 5+1;
=6;
Note:
In program the last & final value is accepted.
**In prefix : First increment / decrement then assign**
If i and j are two variables then :
int i, j ;
i=9;
j=++i;
Output: i & j is : 10 10
Here, Compiler first add 1 to the initial value i=9. Then it
use the new incremented value in the same statement.
**In prefix : First assign then increment / decrement **
If i and j are two variables then :
int i, j ;
i=9;
j=i++;
Output: i & j is : 10 9
Try it yourself:
- -i & i- -
Hint: i = i -1;

More Related Content

What's hot

Presentation on Flip Flop
Presentation  on Flip FlopPresentation  on Flip Flop
Presentation on Flip Flop
Nahian Ahmed
 
VLSI- Unit I
VLSI- Unit IVLSI- Unit I
VLSI- Unit I
MADHUMITHA154
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
Taher Barodawala
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
vishal choudhary
 
Encoder and decoder
Encoder and decoderEncoder and decoder
Encoder and decoder
Abid Ali
 
1st Generation Computers
1st Generation Computers 1st Generation Computers
1st Generation Computers
Gaurav Wadhwa
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
PrabinNeupane8
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
sheheryar ahmed
 
Reverse Engineering .NET - Advanced Patching, Playing with IL
Reverse Engineering .NET - Advanced Patching, Playing with ILReverse Engineering .NET - Advanced Patching, Playing with IL
Reverse Engineering .NET - Advanced Patching, Playing with IL
Levis Nickaster
 
Counters
CountersCounters
Counters
Ravi Maurya
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
bhavanadonthi
 
CSL 202, Shift Registers using Flipflops
CSL 202, Shift Registers using FlipflopsCSL 202, Shift Registers using Flipflops
CSL 202, Shift Registers using Flipflops
CKSunith1
 
Z buffer
Z bufferZ buffer
Z buffer
AmitBiswas99
 
Writing Cadence Ocean scripts
Writing Cadence Ocean scriptsWriting Cadence Ocean scripts
Writing Cadence Ocean scripts
Michael Lee
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
Suvendu Kumar Dash
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
SHIVANI SONI
 
Pcb design
Pcb designPcb design
Pcb design
Abu Bakker
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
kparthjadhav
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
Adri Jovin
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
Piyush Rochwani
 

What's hot (20)

Presentation on Flip Flop
Presentation  on Flip FlopPresentation  on Flip Flop
Presentation on Flip Flop
 
VLSI- Unit I
VLSI- Unit IVLSI- Unit I
VLSI- Unit I
 
Bresenham circle
Bresenham circleBresenham circle
Bresenham circle
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
 
Encoder and decoder
Encoder and decoderEncoder and decoder
Encoder and decoder
 
1st Generation Computers
1st Generation Computers 1st Generation Computers
1st Generation Computers
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
Reverse Engineering .NET - Advanced Patching, Playing with IL
Reverse Engineering .NET - Advanced Patching, Playing with ILReverse Engineering .NET - Advanced Patching, Playing with IL
Reverse Engineering .NET - Advanced Patching, Playing with IL
 
Counters
CountersCounters
Counters
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
 
CSL 202, Shift Registers using Flipflops
CSL 202, Shift Registers using FlipflopsCSL 202, Shift Registers using Flipflops
CSL 202, Shift Registers using Flipflops
 
Z buffer
Z bufferZ buffer
Z buffer
 
Writing Cadence Ocean scripts
Writing Cadence Ocean scriptsWriting Cadence Ocean scripts
Writing Cadence Ocean scripts
 
CISC & RISC Architecture
CISC & RISC Architecture CISC & RISC Architecture
CISC & RISC Architecture
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Pcb design
Pcb designPcb design
Pcb design
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 

Viewers also liked

Bad and good relationships
Bad and good relationshipsBad and good relationships
Bad and good relationships
eoihelen
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
IamPe Khamkhum
 
Best Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing TechniquesBest Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing Techniques
Tech
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
Ibrahim Reda
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Sachin Goyani
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Hüseyin Ergin
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
Chong-Kuan Chen
 
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
vinay arora
 
Prefix Postfix
Prefix PostfixPrefix Postfix
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
Sayali Shivarkar
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
eShikshak
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
Jordan Delacruz
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Elizabeth de Leon Aler
 
PLAZA 3.0 - an access point for plant comparative genomics
PLAZA 3.0 - an access point for plant comparative genomicsPLAZA 3.0 - an access point for plant comparative genomics
PLAZA 3.0 - an access point for plant comparative genomics
Klaas Vandepoele
 

Viewers also liked (20)

Bad and good relationships
Bad and good relationshipsBad and good relationships
Bad and good relationships
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
C lects (3)
C lects (3)C lects (3)
C lects (3)
 
Best Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing TechniquesBest Techniques To Design Programs - Program Designing Techniques
Best Techniques To Design Programs - Program Designing Techniques
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
 
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & FlowchartC Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
C Prog. - Introduction to Hardware, Software, Algorithm & Flowchart
 
Prefix Postfix
Prefix PostfixPrefix Postfix
Prefix Postfix
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
PLAZA 3.0 - an access point for plant comparative genomics
PLAZA 3.0 - an access point for plant comparative genomicsPLAZA 3.0 - an access point for plant comparative genomics
PLAZA 3.0 - an access point for plant comparative genomics
 

Recently uploaded

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
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
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
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
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
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 

Recently uploaded (20)

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...
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
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
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
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
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 

What is difference between Prefix & Postfix (++i ,--i & i++ , i--)

  • 1. What is difference between Prefix & Postfix (++i ,--i & i++ , i--)
  • 2. So what is the difference???? Prefix Postfix The ++ or -- symbol is used before the variable. The ++ or -- symbol is used after the variable. Example: ++i or --i Exmple i++ or i-- It means : i= i+1 or It means: i= i+1 or i= i-1 i= i-1
  • 3. It will be easy for u to understand these if u keep two things in ur mind. That is : In prefix : First increment / decrement by 1 then assign . In postfix: First assign then increment/ decrement by 1 .
  • 4. In prefix: int i =5; ++i; Output: 6 It works like: i = ++i ; // First increment = i+1; = 5+1; = 6; int i = 6; // Then assign Note: In program the last & final value is accepted. In postfix: int i =5; i++; Output: 6 It works like: int i = 5; // First assign i =i++; // Then increment = i+1; = 5+1; =6; Note: In program the last & final value is accepted.
  • 5. **In prefix : First increment / decrement then assign** If i and j are two variables then : int i, j ; i=9; j=++i; Output: i & j is : 10 10 Here, Compiler first add 1 to the initial value i=9. Then it use the new incremented value in the same statement.
  • 6. **In prefix : First assign then increment / decrement ** If i and j are two variables then : int i, j ; i=9; j=i++; Output: i & j is : 10 9
  • 7. Try it yourself: - -i & i- - Hint: i = i -1;