I'm new to coding and to me this code looks ok but it isnt returning the values it should. I really dont know how to correct this! Please help
Code:
# include <stdio.h>
# include <conio.h>
int main()
{
/* Variables */
float root;
float guess;
float answer;
answer = guess*guess;
printf ("Please enter a number that you wish to guess the square root of ");
scanf ("%f",&root);
printf ("\nPlease enter your guess ");
scanf ("%f", &guess);
answer = guess*guess;
while (answer == root)
printf ("\nWell done. your guess is exactly the square root");
if (answer < root)
answer = guess*guess;
{
printf ("\nYour guess is lower than the square root of %f. Please enter a higher guess ", root );
scanf ("%f", &guess);
if (answer > root)
answer = guess*guess;
printf ("\nYour guess is higher than the square root of %f. Please enter a lower guess ", root );
scanf ("%f", &guess);
if (answer + 0.05 == root)
answer = guess*guess;
printf ("\nYour guess of %f is within 0.5 of the square root of %f ", guess, root);
scanf ("%f", &guess);
if (answer - 0.05 == root)
answer = guess*guess;
printf ("\nYour guess of %f is within 0.5 of the square root of %f ", guess, root);
scanf ("%f", &guess);
}
getch();
}