1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    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,292
    Likes Received:
    365
    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:
    Thank you. I wasn't aware of this operator.
     

Share This Page