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

  • Home
  • SEARCH
  • 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 650271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:02:05+00:00 2026-05-13T22:02:05+00:00

In C operation associativity is as such for increment, decrement and assignment. 2. postfix

  • 0

In C operation associativity is as such for increment, decrement and assignment.

  2. postfix ++ and -- 
  3. prefix ++ and -- 
  16. Direct assignment = 

The full list is found here Wikipedia Operators in C

My question is when we have

int a, b;

b = 1;
a = b++;

printf("%d", a); // a is equal to 1

b = 1;
a = ++b;

printf("%d", a); //a is equal to 2

Why is a equal to 1 with b++ when the postfix increment operator should happen before the direct assignment?

And why is the prefix increment operator different than the postfix when they are both before the assignment?

I’m pretty sure I don’t understand something very important when it comes to operation associativity.

  • 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-13T22:02:05+00:00Added an answer on May 13, 2026 at 10:02 pm

    The postfix operator a++ will increment a and then return the original value i.e. similar to this:

    { temp=a; a=a+1; return temp; }
    

    and the prefix ++a will return the new value i.e.

    { a=a+1; return a; }
    

    This is irrelevant to the operator precedence.

    (And associativity governs whether a-b-c equals to (a-b)-c or a-(b-c).)

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

Sidebar

Related Questions

I have a timely operation that runs on a background thread. While running, I
For a one-shot operation, i need to parse the contents of an XML string
How can the XOR operation (on two 32 bit ints) be implemented using only
I have a simple web service operation like this one: [WebMethod] public string HelloWorld()
Trying to perform a single boolean NOT operation, it appears that under MS SQL
Shouldn't this be a pretty straightforward operation? However, I see there's neither a size()
Or is there a chance that the operation will fail? Thanks. I chose the
I need to do a modulus operation on very large integers. The biggest integer
Is std::string size() a O(1) operation? The implementation of STL I'm using is the
Obviously it gets updated during a write operation, but are there any non-destructive operations

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.