# Thread: [Code] Help with identifying errors

1. ## [Code] Help with identifying errors

Hello! I need help in identifying errors here and corrections is needed actually...

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

int main()
{

float temp;
char child;
int i;

printf("Children A&E Department.  We can only treat 3 children each time. \n\n");
for (i = 0; i < 3; i++);
{
printf("Enter body temperature of patient %d in degree Celcius: ", i + 1);
scanf("%.1f",  &temp);

for (;; // forever loop
{
printf("Is patient a child age 0 to 11 (y/n): ");

fflush(stdin);   //need to have  fflush(stdin);  if you scanf(“%c”, …) to read a char from user
scanf("%c", &child);
if (child = 'y' || child = 'n');   //will repeat until user enters 'y' or 'n'.
{
break;
}
}
if (child = 'y');
{
if (temper < 36.6);
{
printf("Child patient's temper of %.1f deg Celcius is Below Average \n", &temp);
}
else if (temper <= 37.2);    //else if (temper >= 36.6 && temper <= 37.2)
{
printf("Child patient's temper of %.1f deg Celcius is Normal \n", &temp);
}
else   //fever if body temperature is > 37.2 Deg Celcius
{
printf("Child patient's temper of %.1f deg Celcius is Above Normal. Fever ! \n", &temp);
}
}
else
{
printf("This is Children A&E Department here. Please go to Normal A&E Department. \n");
i--;    //this loop is skipped (i.e. this loop is a “don’t care”), so don’t let i increment by one
// continue;   //continue; will skip this loop, and go to i++ of for loop
}
}
return 0;
}```

2. After a quick glance, look at this snippet:

Code:
```
for (;; // forever loop   /////////// Missing a closing parentheses.
{
printf("Is patient a child age 0 to 11 (y/n): ");

fflush(stdin);   //need to have  fflush(stdin);  if you scanf(“%c”, …) to read a char from user   NO, this invokes undefined behaviour, fflush() is only defined to be used with output streams.
scanf("%c", &child);```
Instead of invoking undefined behaviour with fflush() just tell scanf() to skip leading whitespace (scanf(" %c", &child) (notice the leading whitespace).

3. Looks like a "fix the errors" homework.
Tutor hands students some code with errors deliberately added, and it's the students job to fix it.