Close
Close

ternary operator

   aMiT PaThAk

# include <stdio.h>

int main() {

int y=1,x=0;

int z =(x++, y++) ?y:x;

printf(“%d\n”,z);

return 0;

}

In this code how (x++,y++) will decide wheather to print y or x


Answers

  •   

    x++, y++ – You are using the comma operator here. It is similar to calling just y++. As the result of x++ will be discarded.


    • ok, it means here y is assign to z, as ++ has higher precedence so value of z is 2 here, but have one doubt when i make y to 0 then it should again print the value of y as ++ operator make it to 1 which in turns print y but here it is printing value of x instead. why it is happening.
      - aMiT PaThAk
    • or it would always be true, printing only y every time.
      - aMiT PaThAk
    • It all depends on whether the condition is true or not. If the condition evaluates to 0, then x will get printed.
      - Amit Kumar

  •    Francis_Bacon

    The review of justdomyessay on globalhack.com was very detailed and provided me with a good understanding of the company and their services. Highly recommend!



  •    SanrioFan

    Richard Mille Replica will help you experience what it's like to wear a great watch without overpaying for a brand. This watch not only replicates the design of the original, but also reproduces the inner workings, ensuring accuracy and durability. Allow yourself to enjoy chic and status by choosing a replica at an affordable price.



  •    meeloun

    许多英文Essay代写    http://www.proessay.cn/our_service1.php    机构拥有专业的团队,他们对于作业有深厚的理解和丰富的经验。因此,通过英文Essay代写服务,消费者可以获得高质量的作业。



  •    tellsteve98

    For instance, I really dig the chunky chronograph pushers, a clear callback to the old-school Super Autavia dashboard timers.replica vacheron-constantin uhren Gary's Rolex Air-King was his first Rolex, and it spent on a lot of time on his wrist while he was researching his latest novel, Lake Success.It seems like there is something new to celebrate every day these days.It wasn't long, however, before IWC diver's watches became the vehicle for a most interesting innovation: the use of titanium.orologi replica rolex



Ask Yours
Post Yours
Write your answer