I have a task to create a program using C language. The program is Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who lives in Texas.
I have done a lot to my code but I can’t seem to get the average age of the family to work. If I can get any help I would appreciate that. Here is my code so far. I am very new to this so anything would be great.
#include <stdio.h>
#include <string.h>
int main(void)
{
int names,age;
char state[50], name[50];
float sum, avg;
for (names=0; names<50; names++)
{
// reset Sum to 0
sum =0.0;
printf(“Enter a family members name:\n”, name);
gets(name);
printf(“The name you entered was: %s \n”, name);
printf(“Enter the abbreviation for the State that %s lives in (for example: MD, TX, CA, NY):\n”, name);
gets (state);
printf(“You entered %s \n”, state);
if ( strcmp(state,“TX”)== 0)
printf("%s is from Texas\n", name);
else
printf("%s is not from Texas… \n", name);
for (age=0; age <50; age++)
sum =0.0;
printf (“Enter Age: \n”);
scanf("%d", &age);
while (age<50)
avg = age/50;
printf( “Average age for family is %f \n”,avg);
}
return 0;
}