solve it and tell me how it works?

Discussion in 'C' started by Ankur Kamboj, Aug 1, 2011.

  1. Ankur Kamboj

    Ankur Kamboj New Member

    Joined:
    Jun 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    main(){
    int i = 10, j =20;
    j = i ,j?(i,j)?i :j:j;
    printf(“%d\n%d”,i,j);
    }

    the answer is 10 10
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    See the use of comma operator and it will be clear why you have that as a answer.
     
  3. Ankur Kamboj

    Ankur Kamboj New Member

    Joined:
    Jun 19, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    thanks alot...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice