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 8740383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:07:18+00:00 2026-06-13T11:07:18+00:00

Why is k not getting incremented whereas,i and j are getting incremented in the

  • 0

Why is k not getting incremented whereas,i and j are getting incremented in the same expression.And i also want to know what is the output of the program.I am getting the output as
-2 3 1 0

#include <stdio.h>
void main()
{
 int i=-3, j=2, m, k=0;
 m=++i && ++j || ++k;
 printf("%d %d %d %d", i, j, m, k);
}
  • 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-06-13T11:07:20+00:00Added an answer on June 13, 2026 at 11:07 am

    The logical or, || short-circuits, and after

    ++i && ++j
    

    the value of the entire expression is determined, so the right operand of the || isn’t evaluated.

    m=++i && ++j || ++k;
    

    is parenthesized m = (++i && ++j) || ++k; since the && has higher precedence than the ||.

    The short-circuiting of the logical operators means that the right operand is only evaluated when the evaluation of the left has not yet determined the final result, for || that means the right operand is only evaluated if the left evaluated to 0, and for &&, the right operand is only evaluated if the left evaluated to a nonzero value.

    So first ++i && ++j is evaluated, and for that, first ++i is evaluated. i had the value -3 before, so ++i evaluates to -2, which is not 0, hence the ++j is evaluated too. j had the value 2 before, so ++j evaluates to 3, which is again nonzero, and thus ++i && ++j evaluates to 1 (true). Since the left operand of the || is not zero, its result is already determined (to be 1), and the right operand isn’t evaluated, thus k remains unchanged and m is set to 1.

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

Sidebar

Related Questions

Really simple but just not getting it. I want to reference a view by
I am not getting that how to differentiate same element name for eg City,Area
I'm not getting the syntax right. Lets say I have this... #include <set> ...
I'm not getting any rows returned with the following, and I don't know why.
I'm not getting any anti-aliasing when using drawing GL_TRIANGLE_FANs with this code: glDisable(GL_DEPTH_TEST); //
I am not getting any error message in browser due to curly brace missing
My serializable class is not getting read in with objectinputstream after adding static methods
I'm simply not getting this to work. I saw that this network isn't for
Hey im not getting anywhere with turning wcf into a restful service. So I
I'm still not getting exactly how a custom CursorAdapter should work, so after hard

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.