initalization Query !

Discussion in 'C' started by Bhullarz, Apr 7, 2008.

  1. Bhullarz

    Bhullarz New Member

    Joined:
    Nov 15, 2006
    Messages:
    253
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    System Manager
    Home Page:
    http://www.tutors161.com
    Code:
    #include<stdio.h>
    int main()
    {
    int i=(2,3);
    printf("%d",i);
    }
    
    output of the program would be:
    Code:
     3 
    i don't understand why it is 3 as far as i know one variable can be assigned one value at one time,but here we are assigning 2 values,but still this program is error/warning free and giving output.

    kindly explain the reason.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    Read about the comma operator and it will become clear to you
     
  3. Bhullarz

    Bhullarz New Member

    Joined:
    Nov 15, 2006
    Messages:
    253
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    System Manager
    Home Page:
    http://www.tutors161.com
    Thank you. I wasn't aware of this operator.
     

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