Friday, 10 May 2013

c programming

main()
{
int a= 0,b = 20;
char x =1,y =10;

if(a,b,x,y)
printf("hello");
}
Answer:
.
.
.
.
.
.
.
.
.
.
hello

Explanation:
The comma operator has associativity from left to right. Only the rightmost value is returnedand the other values are evaluated and ignored. Thus the value of last variable y is returned tocheck in if. Since it is a non zero value if becomes true so, "hello" will be printed

No comments:

Post a Comment

Blog Archive