Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   initalization Query ! (http://www.go4expert.com/forums/initalization-query-t9826/)

Bhullarz 7Apr2008 14:50

initalization Query !
 
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.

shabbir 7Apr2008 15:01

Re: initalization Query !
 
Read about the comma operator and it will become clear to you

Bhullarz 7Apr2008 18:11

Re: initalization Query !
 
Thank you. I wasn't aware of this operator.


All times are GMT +5.5. The time now is 09:28.