EmbLogic's Blog

what its output & why

{
int i, j, k;
i = -1;
j = 1;
k = 1;
++i && j++ || ++k;
printf(“%d %d %d\n”,i,j,k);

return 0;

5 Responses to what its output & why

  1. anil rajak says:

    0,1 and -1
    in and operator both condition must be satisfied
    but in case of or operator if any one condition is true it doesnot check the second
    condition.

  2. anil rajak says:

    implemented client server project using sockets

  3. pravin bhalerao says:

    done client server project using sockets…

  4. msiddarth says:

    Hi
    In AND logic operation if statement A is false then the compiler will not check the statement B. However, if statement A is true then the compiler will check the condition of statement B.
    In OR operation if statement A is true then the compiler will not check the statement B. However, if statement A is false then it will check the statement B.
    In the above problem when i is incremented the value is 0 hence it won’t check the condition for j however the result of AND operation will be checked with K in OR condition. Hence the value of i: 0, j: 1 and k: 2

  5. jatinder singh says:

    thanku sir

Leave a Reply to msiddarth Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>