need help to add or subtract 50% of guess after user responds h or l
CODE
#include <stdio.h>
int main(void)
{
int guess = 50;
int min_number = 1;
int max_number = 100;
char response;
printf("Pick an integer from 1 to 100. I will try to guess");
printf("it.\nRespond with h if my guess is high, with");
printf("\nan l if it is low and with c if correct.\n");
printf("Is your number %d?\n", guess);
while ((response = getchar()) != 'c') /*get response, compare to c */
{
if
(response == 'l' && guess <= max_number)
printf( "Well, then, is it %d?\n", ++guess*1.50);
if
(response == 'h' && guess >= min_number)
printf("Well, then, is it %d?\n", --guess);
if
(response == 'c')
printf(" I knew I could do it!\n");
else
printf("Sorry, I understand only l, h or c.\n");
while (getchar() != '\n')
continue;
}
return 0;
}