if we set float and double type to NaN then they are not equal to anything including themselves.
can such a thing happens for
It cannot happen when you compare plain initialized int variables.
It can happen for int comparisons when you reference a hardware register, e.g. something like:
*timeRegister == *timeRegister
It could also happen when you compare a volatile int variable to itself which is modified by a signal-handler during the comparison.