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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:05:17+00:00 2026-05-23T11:05:17+00:00

#include <stdio.h> int main () { int x, y, z; x = y =

  • 0
#include <stdio.h>

int main () {
    int x, y, z;

    x = y = z = 1;
    ++x || ++y && ++z;
    printf ("x = %d\t y = %d\tz = %d\n", x, y, z);
    //op  :   x = 2    y = 1  z = 1 
    //why is 'x' only incrementd? 

    x = y = z = -1;
    ++x || ++y && ++z;
    printf ("x = %d\t y = %d\tz = %d\n", x, y, z);
    //op  :  x = 0    y = 0  z = -1
    //why are 'x' and 'y' incremented?

    x = y = z = 1;
    ++x && ++y || ++z;
    printf ("x = %d\t y = %d\tz = %d\n", x, y, z);
    //op  : x = 2    y = 2  z = 1
    //why is 'x' only incrementd?

    x = y = z = -1;
    ++x && ++y || ++z;
    printf ("x = %d\t y = %d\tz = %d\n", x, y, z);
    //op  : x = 0    y = -1 z = 0
    //why are 'x' and 'z' incremented?

    //Does this incrementation depend on the value stored in the variable?
}
  • 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-23T11:05:17+00:00Added an answer on May 23, 2026 at 11:05 am

    || and && short-circuit. What that means is that they perform as little work as possible to return their value, only executing the right side if the left side doesn’t nail the answer.

    For instance:

    1 || anything();
    

    In this case, anything() will never execute, because || can simply return as soon as it evaluates the 1; no matter what anything()’s return value, the return value of || in this expression can never be 0.

    Similarly:

    0 && anything_else();
    

    Here, anything_else() will never execute, because && already knows that its value can never be anything but 0.

    In your examples, the ++ preincrements don’t actually affect the short-circuiting, except to hide the values that the boolean short-circuit operators are actually making their decisions on.

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

Sidebar

Related Questions

#include<stdio.h> void function(int); int main() { int x; printf(Enter x:); scanf(%d, &x); function(x); return
In following code, #include<stdio.h> int main() { short a[2]={5,10}; short *p=&a[1]; short *dp=&p; printf(%p\n,p);
#include<stdio.h> int main() { char a, b; scanf(%c, &a); scanf(%c, &b); printf(%c %c,a,b); return
consider the code #include<stdio.h> int main(void) { char* a; scanf(%s,a);//&a and &a[0] give same
#include<stdio.h> #include<time.h> int main() { clock_t start; double d; long int n,i,j; scanf(%ld,&n); n=100000;
#include <stdio.h> int main() { float a = 1234.5f; printf(%d\n, a); return 0; }
#include<stdio.h> int main() { printf(He %c llo,65); } Output: He A llo #include<stdio.h> int
#include<stdio.h> int main() { char a[5]=hello; puts(a); //prints hello } Why does the code
#include<stdio.h> int main() { int a,b; a=a+b; printf(%d,a); return 0; } what should be
#include<stdio.h> #include<conio.h> int main(){ char i; int c; scanf(%i,&c); scanf(%c,&i);// catch the new line

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.