Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 683851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:45:11+00:00 2026-05-14T01:45:11+00:00

I have never seen the usecase for pre-increment and post-increment in actual code. The

  • 0

I have never seen the usecase for pre-increment and post-increment in actual code. The only place i see them most often are puzzles.
My opinion is, it introduces more confusion rather than being useful.

  • is there any real use case scenario for this
  • can’t this can be done by using +=

    y = x++

    y = x
    x += 1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:45:11+00:00Added an answer on May 14, 2026 at 1:45 am

    It’s just a shorter way of writing the same thing and it’s only confusing to those who don’t deeply understand C (a). The same argument could be made for replacing:

    for (i = 0; i < 10; i++)
        printf ("%d\n", i);
    

    with:

    i = 0;
    while (i < 10) {
        printf ("%d\n", i);
        i = i + 1;
    }
    

    since any for can also be done with while, or:

    i = 0;
    loop: if (i < 10) {
        printf ("%d\n", i);
        i = i + 1;
        goto loop;
    }
    

    since any loop construct can be built out of conditions and goto. But (I’m hoping) you wouldn’t do that, would you?


    (a) I sometimes like to explain this to my students as simple statements and side effects, something that allows C code to be more succinct with usually no or minimal loss in readability.

    For the statement:

    y = x++;
    

    the statement is assigning x to y with the side effect that x is incremented afterwards. ++x is the same, it’s just that the side effect happens beforehand.

    Similarly, the side effect of an assignment is that it evaluates as the value assigned, meaning you can do things like:

    while ((c = getchar()) != -1) count++;
    

    and which makes things like:

    42;
    

    perfectly valid, but useless, C statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read about pointers to class members, but I have never seen them
I have never seen this being done anywhere in all the source code i've
I'm reviewing some code, and saw something I have never seen before. I did
I don't grok Perl subroutine attributes at all. I have never seen them in
I have never seen this before, the rows will be sequential but I have
I have never seen a buffer overflow exploit in live action. Suppose I found
I'm wondering why I have never seen the following way to implement templates in
I am not strong on my PHP knowledge, but I have never seen this
I have seen many souce codes but I have never ever come across a
I have seen this talked about but never answered. Maybe it has and I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.