Mithlesh Upadhyay Mithlesh Upadhyay - 2 months ago 15
C++ Question

Is `0<0` true or false?

#include <iostream>
#include <string>

int main()
{
int i=0;
while(i++<0)
i--;
}





My attempt:

I do compile and run this program, it will be executed and printed nothing(nothing is given).

Can you explain it,
0<0
is true or false?

Answer

0<0 is false same as 42<42 is false (or any other equal integer). The < returns true when the LHS of the operator is less than the RHS i.e. it returns false when the LHS is greater or equal to the RHS.

Comments