I am trying to run this program until user wants but unable to.
I have tried using do-while loop but couldn't achieve the desired output
float water_level;
char command;
do{
printf("Enter the water level sensor readout in meters : \n");
scanf("%f",&water_level);
printf("The water level is: %f \n",water_level);
if(water_level <= 0.5)
{
printf("The output valve is turned OFF \n");
}
else
printf("The output valve is turned ON \n");
if(water_level < 3.0)
{
printf("The water pump is turned ON \n");
}
else
printf("The water pump is turned OFF \n");
printf("Do you want to run the program Again? \n Type y or n \n");
command = scanf("%c",&command);
} while(command == 'y');
}