I have a program that prints out the smallest of 3 numbers. I'm trying to use a combination of "0 0 0" as my sentinel control to stop the program. However if I define a SENTINEL constant as 0 and then plug it into my loop, I get a syntax error. So I'm using the way below. (Becuase this is for school some of it has been omitted for reasons I'm sure everyone is aware of
Code:
#include <stdio.h>
int main()
{
double num1, num2, num3, smallest;
printf("Enter three numbers: ");
scanf("%lf%lf%lf", &num1, &num2, &num3);
while (num1 !=0 && num2 !=0 && num3 != 0)
{
if (num1 < num2 && num1 < num3)
{
smallest = num1;
}
else if (...)
{
...;
}
else if (...)
{
...;
}
printf("The smallest number was %.3lf\n", smallest);
printf("Enter three numbers: ");
scanf("%lf%lf%lf", &num1, &num2, &num3);
}
return 0;
}
The problem is if I enter 0 as any of the 3 numbers it stops the program. I only want it to stop if 0 0 0 is entered. Can someone help me out with this?
Also, how come I get a syntax error if I replace the "0" with SENTINEL?
thanks