1. ## Code trouble

I need to have the program calculate the area of a circle from the inputs, converting degrees to radians, and checking for correct inputs such as letters instead of numbers or negative lengths. Here is the code I have:
Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.1415926
int main()
{
double base;
double angleD;
double angleR;
double area;
int in;
char buffer[128];

while (1)
{
printf("Would you like to continue?(Y/N)  ");
if((in = getchar()) == 'Y' || (in = getchar()) == 'y')
while (1)
{
printf("Enter Base Length and Angle in degrees(Less than 90):   ");
gets(buffer);
int x = sscanf(buffer, "%lf %lf", &base, &angleD);
if(x == 2)
{
if(base > 0 && angleD > 0)
{
angleR = angleD * PI / 180;
area = base * base * tan(angleR) / 2;
printf("Area is %7.4f\n", area);
break;
}
else
{
}
}
else
{
}
}
else
{
printf("Thank you!\n");
break;
}
}
}```
The problem is I get this when I try to run it as well as not accepting the lower case 'y':

Would you like to continue?(Y/N) Y
Enter Base Length and Angle in degrees(Less than 90): Please enter numbers only.
Enter Base Length and Angle in degrees(Less than 90):

I know it's a mess but I'm out of ideas and so are the other people I know who have any C experience. If you need anything cleared up let me know

2. Well, I suggest converting the input to lowercase to analyze it. Also looks like you are getting your parentheses messed up.

Code:
```#include <ctype.h>

in = tolower(getchar());
if (in == 'y')
...
else
...```

3. Thanks, that fixed the upper and lower 'y' issue.

4. Also, use fgets() in place of gets(), see the FAQ for why.

5. Thanks for the help. It's not pretty but it will be a grade in the book.