I cant figure why my program is not running it compiles with no errors but doesnt run, am bearly starting to learn c , am more proefficient in java but its wierd changing, i use vi to write my code. heres a snipet
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
main()
{
int numberofplays = 0;
float average = 0;
int numberguesses = 0;
printf("Playing guess my number game\n");
printf("-------------------------------\n");
bool play = true;
int xtry = 0;
int totaltries = 0;
char answer;
while(play==true)
{
xtry = playgame();
numberofplays++;
totaltries = totaltries + xtry;
printf("Play again? (y for yes n for no): ");
answer = getchar();
if(answer =='n')
{
play = false;
}
}
average = totaltries/numberofplays;
printf("average is %f tries per game\n",average);
return 0;
}
int playgame()
{
int guessnumber = 50;
int xnumber = 25;
int count=0;
char x;
bool stillguessing = true;
while(stillguessing == true);
{
printf("is your number %d ?", guessnumber);
x = getchar();
if(x=='=')
{
count++;
printf("Great!\n");
stillguessing=false;
return count;
}
else if(x == '<')
{
guessnumber = guessnumber - xnumber;
xnumber = xnumber/2;
if(xnumber<1)
xnumber = 1;
count++;
}
else if (x == '>')
{
guessnumber = guessnumber +xnumber;
xnumber = xnumber/2;
if(xnumber<1)
xnumber = 1;
count++;
}
}
}
My program is basically a guessng game where user thinks a number from 1-100 in his head and my prgram guesses the number , the user enters <,>,= when the guessed number is either less , more or equal