So this program is supposed to guess a number which you though in your mind. But if you run it and see after asking you the first question it doesnt take anymore input.
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("Enter the upper limit for the range of numbers:\n");
int n;
scanf("%d", &n);
int low=0;
int high=n;
printf("Answers should only be y for yes or n for no.\n");
do{
int median;
median=(high+low)/2;
printf("Is your number greater than %d median?\n", median);
char ans;
scanf("%c", &ans);
if(ans=='y' || ans=='Y'){
low=median;
continue;
}
else{
printf("Is your number smaller than %d median?\n", median);
scanf("%c", &ans);
if(ans=='y' || ans=='Y'){
high = median;
continue;
}
else
{
low = high = median;
}
}
}while(low != high);
printf("Your number is: %d\n", low);
return 0;
}