I need to use an if/else statement like the following in another program of mine, but for some reason there is a problem with it.
The statement seems to work for all values, except when I enter the N_MAX value of 0.1. It should be considered valid, but it's not. The thing that's really puzzling is that if I enter 0.001 I get valid, yet the same won't happen for 0.1.
#include <stdio.h>
#include <stdlib.h>
#define N_MIN 0.001
#define N_MAX 0.1
int main()
{
float num;
printf("Enter a number.\n");
scanf("%f", &num);
if(num < N_MIN || num > N_MAX)
{
printf("Invalid.\n");
}
else
{
printf("Valid.\n");
}
system("PAUSE");
return(0);
}