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 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've got to the section on operators in The Ruby Programming Language , and
Which operation should be faster on a x86 CPU on Linux and what are
Possible Duplicate: Cross-thread operation not valid: Control accessed from a thread other than the
Where do you see operation scenarios for parallelism/multi-threading/PLINQ etc for a single threaded WPF
Why is a mod ( % ) operation more expensive than a multiplication (
Is there a bit operation or a series of bit operations that would give
I have multithreaded operation running, each one append some info to my log file.
I have Operation Aborted each time I Refresh my website's page. I read the
Perl has a conditional operator that is the same a C's conditional operator .
Which is more performant: ($longstring . $longstring) . $longstring , or $longstring . ($longstring

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.