Thursday, July 30, 2009

Is n1k = fChange == < 999 / 1000; a legal statement in C programming?

is


n1k = fChange == %26lt; 999 / 1000;





a legal staement in C programming?

Is n1k = fChange == %26lt; 999 / 1000; a legal statement in C programming?
no it is not legal.


==%26lt; is not an operator in C, u can use =%26lt;.


i.e.


n1k=fchange=%26lt;999/1000;





and now what is the output of this one?


n1k will be 1, if fchnage is equal to or less than.1


why?


coz...


999/1000 gives 0.999


it is convert to integer i.e. 1.


after that assign in n1k.
Reply:n1k = fChange is an assignment operator. ==%26lt; is not even valid, it needs to be either == or %26lt;= (or just %26lt;). You can't assign and compare on the same statement.
Reply:I don't believe so.





My reason being that == is an operator, and so is %26lt;. These cannot be used one after the other without anything in between, and this wouldn't compile because of it.


No comments:

Post a Comment