DEV Community

Cover image for What are i++ or ++i or i-- or --i in programming language?? Why you should use them?
Md. Fahim Bin Amin
Md. Fahim Bin Amin

Posted on

3 1

What are i++ or ++i or i-- or --i in programming language?? Why you should use them?

In our programming learning, we frequently use the i++ or ++i, i-- or --i.

Sometimes, it is pretty tricky to understand why we use them and how they actually work in different perspective.

However, I have discussed everything in a video.

📹 Make sure to watch it to understand better.

Let me also clarify what we call those 4 specific things:

  • i++: Post increment
  • ++i: Pre increment
  • i--: Post decrement
  • --i: Pre decrement

You can connect me via:

🎁 LinkedIn, Twitter, GitHub, English YouTube Channel, Bengali YouTube Channel

🖼️ Cover: Photo by Nate Grant on Unsplash

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (2)

Collapse
 
phlash profile image
Phil Ashby

Typo :) "--i: pre-increment" should probably say pre decrement.

It's interesting to note that some popular languages do not support these operators for safety reasons, notably: Python & Rust.

Personally I try to avoid these operators unless I need the result of the expression and it's an idiomatic form eg in C: *p++ = val; particularly in the third term of a for loop, where I prefer val += 1 which is more portable.

Collapse
 
fahimfba profile image
Md. Fahim Bin Amin

Thank you so much for the correction. I did a mistake there for having a rush! Silly me 😅

That's also true, but we tend to use that in Java, C/C++ a lot to be honest.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more