Trying to validate an entry, New to C
The program compiles, but when I enter the number 22 it falls out of the while loop. I want to tell the operator that they entered an incorrect value and please try again and again.... if neccessary. I am not sure where my logic is flawed.
Thank You for lookin at this.
Code:
/*
*Loop till valid entry with message
*/
#include <stdio.h>
int main(void)
{
double value; // stores numerical value
int exitvalue; //declatarations
exitvalue=0; //initialize variable
do
{
// ask for and get numeric value
printf("Please enter numeric value between 1 and 10: \n");
scanf("%lf", &value );
if (value< 1 || value>10) // check to see if value less than 1 OR greater than 10
{
exitvalue=0;
printf("Invalid entry please try again\n"); // value is outside of acceptance range - loop again
}
else
{
exitvalue=1; //value is in acceptance range - exit while loop
}
}
while (exitvalue==1); //exit when exitvalue is equal to 1
printf("condition met \n");
return (0);
}