I am trying to use a sentinel value to control the loop. However, if I set the sentinel value to be a char, to be entered from keyboard, the loop never repeats itself. But if I set the sentinel value to be an int such as 1, it worked.
The code is as following. Could you please help me out?
Code:Code:int main(void) { double miles, kms; char sentinel; printf("Run the conversion program (y/n)? "); scanf("%c", &sentinel); while (sentinel=='y') { printf("Enter the distance in miles> "); scanf("%lf", &miles); kms=miles*1.609; printf("You traveled %.3f kilometers.\n\n", kms); printf("Run the conversion program (y/n)? "); scanf("%c", &sentinel); } return (0); }