[Solved] C Programming Problem Would Really Appreciate Help Assignment Please Testing Program Files Q37224849
C Programming Problem // I would really appreciate somehelp with this assignment please

![ageSearch - receives the front pointer of a family (families[i].front), last name (families[i].last) and an int (an age) and](https://media.cheggcdn.com/media%2F8c7%2F8c7b831c-dcd4-4659-9bb8-8078d71d8706%2FphpGeK6fY.png)
![this age to the ageSearch function and the front pointer of each family (e.g families[i].front), and the familys last name (](https://media.cheggcdn.com/media%2Fd4f%2Fd4fca60a-0ceb-437e-a3eb-5a88c1a66657%2Fphpp93zf1.png)
You can do the testing of the program with the files below thatshould be able to be copy and pasted into your own .txt file.
InputFamily1.txt File
Steve Howe M 61
Ruth Underwood F 40
Frank Zappa M 53
Jemma Wakeman F 29
Virgil Howe M 29
Dylan Howe M 28
Rick Wakeman M 57
Steve Hackett M 56
Ian Underwood M 41
Moon Zappa F 28
Georgia Howe F 33
Jo Hackett F 52
Diva Zappa F 22
John Hackett M 61
Gail Zappa F 50
Rachel Wakeman F 53
Janet Howe F 57
Dweezil Zappa M 29
Oliver Wakeman M 28
InputFamily2.txt File
Stan Marsh M 9
Marge Simpson F 36
Kerry Mackleberry F 36
Brittany Spuckler F 4
Stuart McCormick M 31
Homer Simpson M 39
Todd Flanders M 8
Taylor Spuckler F 7
Barry Spuckler M 2
Kaitlyn Spuckler F 12
Milhouse Van_Houten M 10
Gerald Broflovski M 42
Karen McCormick F 5
Carol McCormick F 27
Zoe Spuckler F 3
Cletus Spuckler M 33
Kirk Van_Houten M 41
Rod Flanders M 10
Cassidy Spuckler F 5
Kenny McCormick M 9
Terri Mackleberry F 10
Crystal Spuckler F 7
Sherri Mackleberry F 10
Kyle Broflovski M 10
Dylan Spuckler M 9
Bart Simpson M 10
Birthday Spuckler M 3
Dubya Spuckler M 8
Luann Van_Houten F 39
Heather Spuckler F 10
Larry Mackleberry M 35
Randy Marsh M 45
Lisa Simpson F 8
Whitney Spuckler F 10
Cody Spuckler F 6
Chloe Spuckler F 6
Ned Flanders M 60
Sheila Broflovski F 41
Liane Cartman F 31
Brandine Spuckler F 31
Mary Spuckler F 11
Melvis Spuckler M 11
Kevin McCormick M 6
Sharon Marsh M 41
Shelly Marsh F 13
Maggie Simpson F 1
Eric Cartman M 9
The goal of this assignment is threefold: work with structs, work with linked lists, implement a “database-like” program that stores records that can be queried. Specifically, in this assignment, you will create a struct person and use it to create a struct node so that you can storea linked list of persons. You will then create a struct family and finally an array of struct family. A single struct family will store individual person structs in a linked list. You will implement various linked list functions and some other functions (described later) A person will consist of: first name (string (no more than 10 chars)), age (int) and sex (char). A node will consist of: person and a next pointer (struct node *)-assume that the struct person member has the name me (as used below). A family will consist of a last name (string (no more than 12 chars)), size (int) (that is, the number of people in the family which is the same as the number of structs in the linked list), and a pointer to the front of the linked list of family members (struct node *). You will create an array of your struct family, e.g., struct family families [10] You will need no more than 10 array elements. To access a family, use families [i]. To access the linked list, use families[i].front. Given astruct node temp, to a node in a linked list, to access that person’s name, age and sex use temp- me.first,temp->me.age, temp-me.sex. You are free to name your structs, members and your array variable anything you like, the examples here are just to help you understand the structure of these three struct types and how to access into them. Your program may consist of a single file (if you want to separate functions into multiple files and/or have a header file, that is your choice but it is not needed). After any # statements, define your structs: person, node, family (in that order since node relies on person and family relies on node). Next, define your prototypes (or place your functions prior to main) and then write your functions Aside from main, you will need the following functions (at a minimum) input- input a person’s data from disk file findFamily-given a person’s last name, determine the index 1 in the families array that matches that last name, or use a special value if that family does not yet exist (I use -1). insertPerson – insert a new person (first name, age, sex) into families[i]. This is an ordered insert based on first name. This function should receive a families [i].front (the pointer to this family’s linked list), and the new person’s first name, age and sex. Allocate a new node, copy into this node the person’s first name, age, sex, and insert the node into the linked list, returning a node pointer to the front of the list (needed when inserting into an empty list or at the front of a list) outputFamily – receives a family’s front pointer (e.g., families[i].front) and the family’s last name (e.g., families [i].last) and outputs the family’s last name and then the first names of each person in the family; this is a traversal function to print out the elements of a linked list but only prints first names, not ages or sex . . destroy – a function which receives the entire array of families and n (the number of families in the array), and destroys each family’s linked list, resetting each families [i].number to 0 and families [i].front to NULL ageSearch – receives the front pointer of a family (families[i].front), last name (families[i].last) and an int (an age) and finds and outputs the first and last name of all people in the given linked list who are of the given age . smallestLargest – receives the entire array of families and n, and determines the two families who have the least and most people, outputting those families (use the outputFamily function). If two families have the same size, say families[i] and families[j], then output the one you found first. For instance, if i is the index of the smallest family currently and families[j].number families[i].number, then min remainsi instead of becomingj You may write other functions if or as needed. In main, declare your array of struct family elements (no more than 10). Declare the array statically (do not use a pointer/calloc), and declare any variables you need. Initialize your array of family elements by setting each element’s size to 0 and front pointer to NULL. You do not need to initialize the last names but if you want to, assign them using strepy, not as in strcpy (families [i].last, “) Next in main, use a while loop to iterate through the contents of the input file until you reach EOF. This might look like what you implemented in program 2, for instance while(getInput(…)!-EOF) {…) The input function will need to input1 row of the input text file which will consist of a first name, last name, age and sex. Call the findFamily function to locate the array index in families that is currently storing the given last name, if there is one. In my program, findFamily returned -1 if no such . family was found. If there was no family, then you will add a new array element to families. That will work . as follows: o assume n is the current number of families, then families[n] is an unused array location. Set families[n].number to 1, set families[n].last to the last name as input, and call your insert function passing families[n].front. Remember that insert will return a front pointer, so this should be part of an assignment statement. To assign families[nj.last, you need to use strepy. Finally, increment n. if a family was found, insert the new person into that linked list and add 1 to that o family’s size The insert function will be an ordered insert based on first name. Remember to implement the three cases (empty list, inserting at the front, inserting elsewhere). You will have to malloc a new node. If that node is called temp, to assign temp its first name, age and sex, . the code will look something like this strcpy(temp->me.first, first); temp-me.age-age temp-me.sex-sex After exiting the while loop, use a for loop to iterate through all n families and print out all of the families using your outputFamily function. This function receives families[i].front and families[i].last so that the function can print out the family’s last name and then each first name in the linked list Next, prompt the user to enter an age. Use a second while loop that iterates while age> 0. Search all of the families for anyone whose age is equal to the input age and output that person’s first and last names. This requires a for loop to iterate through all n families and inside the loop, passing this age to the ageSearch function and the front pointer of each family (e.g families[i].front), and the family’s last name (so that you can output full names) Next, call the smallestLargest function which will find the two families with the least/most people Once found, pass that family’s front pointer to the outputFamily function to print out the family’s last name and then each first name. Finally, call the function to destroy all of the linked lists and reset each element of families[i] so that lastName is reset to ” and number is reset to 0 Run your program on the two data files on the website. An example of output from the first run is shown below Printing all families Howe family: Dylan, Georgia, Janet, Steve, Virgil, Underwood family: Ian, Ruth, Zappa family: Diva, Dweezil, Frank, Gail, Moon, Wakeman family: Jemma, Oliver, Rachel, Rick, Hackett family: Jo, John, Steve, Enter an age to search for 53 Searching for all people of age 53: Frank Zappa, Rachel Wakeman, Enter an age to search for 29 Searching for all people of age 29: Virgil Howe, Dweezil Zappa, Jemma Wakeman, Enter an age to search tor: Searching for all people of age 57: Janet Howe, Rick Wakeman, Enter an age to search for 54 Searching for all people of age 54: Enter an age to search for 0 Largest is the Howe family: Dylan,Georgia, Janet, Steve, Virgil, Smallest is the Underwood family: Ian, Ruth, Your output does not have to be formatted like mine but should match these results. If you have trailing commas, like mine, don’t worry about it. After getting your program working, run it on the second input file and search for people whose ages are 39, 42, 61, 10, 16 and 8. Submit your commented code and the output from running the program on the second input file Show transcribed image text The goal of this assignment is threefold: work with structs, work with linked lists, implement a “database-like” program that stores records that can be queried. Specifically, in this assignment, you will create a struct person and use it to create a struct node so that you can storea linked list of persons. You will then create a struct family and finally an array of struct family. A single struct family will store individual person structs in a linked list. You will implement various linked list functions and some other functions (described later) A person will consist of: first name (string (no more than 10 chars)), age (int) and sex (char). A node will consist of: person and a next pointer (struct node *)-assume that the struct person member has the name me (as used below). A family will consist of a last name (string (no more than 12 chars)), size (int) (that is, the number of people in the family which is the same as the number of structs in the linked list), and a pointer to the front of the linked list of family members (struct node *). You will create an array of your struct family, e.g., struct family families [10] You will need no more than 10 array elements. To access a family, use families [i]. To access the linked list, use families[i].front. Given astruct node temp, to a node in a linked list, to access that person’s name, age and sex use temp- me.first,temp->me.age, temp-me.sex. You are free to name your structs, members and your array variable anything you like, the examples here are just to help you understand the structure of these three struct types and how to access into them. Your program may consist of a single file (if you want to separate functions into multiple files and/or have a header file, that is your choice but it is not needed). After any # statements, define your structs: person, node, family (in that order since node relies on person and family relies on node). Next, define your prototypes (or place your functions prior to main) and then write your functions Aside from main, you will need the following functions (at a minimum) input- input a person’s data from disk file findFamily-given a person’s last name, determine the index 1 in the families array that matches that last name, or use a special value if that family does not yet exist (I use -1). insertPerson – insert a new person (first name, age, sex) into families[i]. This is an ordered insert based on first name. This function should receive a families [i].front (the pointer to this family’s linked list), and the new person’s first name, age and sex. Allocate a new node, copy into this node the person’s first name, age, sex, and insert the node into the linked list, returning a node pointer to the front of the list (needed when inserting into an empty list or at the front of a list) outputFamily – receives a family’s front pointer (e.g., families[i].front) and the family’s last name (e.g., families [i].last) and outputs the family’s last name and then the first names of each person in the family; this is a traversal function to print out the elements of a linked list but only prints first names, not ages or sex . . destroy – a function which receives the entire array of families and n (the number of families in the array), and destroys each family’s linked list, resetting each families [i].number to 0 and families [i].front to NULL
ageSearch – receives the front pointer of a family (families[i].front), last name (families[i].last) and an int (an age) and finds and outputs the first and last name of all people in the given linked list who are of the given age . smallestLargest – receives the entire array of families and n, and determines the two families who have the least and most people, outputting those families (use the outputFamily function). If two families have the same size, say families[i] and families[j], then output the one you found first. For instance, if i is the index of the smallest family currently and families[j].number families[i].number, then min remainsi instead of becomingj You may write other functions if or as needed. In main, declare your array of struct family elements (no more than 10). Declare the array statically (do not use a pointer/calloc), and declare any variables you need. Initialize your array of family elements by setting each element’s size to 0 and front pointer to NULL. You do not need to initialize the last names but if you want to, assign them using strepy, not as in strcpy (families [i].last, “) Next in main, use a while loop to iterate through the contents of the input file until you reach EOF. This might look like what you implemented in program 2, for instance while(getInput(…)!-EOF) {…) The input function will need to input1 row of the input text file which will consist of a first name, last name, age and sex. Call the findFamily function to locate the array index in families that is currently storing the given last name, if there is one. In my program, findFamily returned -1 if no such . family was found. If there was no family, then you will add a new array element to families. That will work . as follows: o assume n is the current number of families, then families[n] is an unused array location. Set families[n].number to 1, set families[n].last to the last name as input, and call your insert function passing families[n].front. Remember that insert will return a front pointer, so this should be part of an assignment statement. To assign families[nj.last, you need to use strepy. Finally, increment n. if a family was found, insert the new person into that linked list and add 1 to that o family’s size The insert function will be an ordered insert based on first name. Remember to implement the three cases (empty list, inserting at the front, inserting elsewhere). You will have to malloc a new node. If that node is called temp, to assign temp its first name, age and sex, . the code will look something like this strcpy(temp->me.first, first); temp-me.age-age temp-me.sex-sex After exiting the while loop, use a for loop to iterate through all n families and print out all of the families using your outputFamily function. This function receives families[i].front and families[i].last so that the function can print out the family’s last name and then each first name in the linked list Next, prompt the user to enter an age. Use a second while loop that iterates while age> 0. Search all of the families for anyone whose age is equal to the input age and output that person’s first and last names. This requires a for loop to iterate through all n families and inside the loop, passing
this age to the ageSearch function and the front pointer of each family (e.g families[i].front), and the family’s last name (so that you can output full names) Next, call the smallestLargest function which will find the two families with the least/most people Once found, pass that family’s front pointer to the outputFamily function to print out the family’s last name and then each first name. Finally, call the function to destroy all of the linked lists and reset each element of families[i] so that lastName is reset to ” and number is reset to 0 Run your program on the two data files on the website. An example of output from the first run is shown below Printing all families Howe family: Dylan, Georgia, Janet, Steve, Virgil, Underwood family: Ian, Ruth, Zappa family: Diva, Dweezil, Frank, Gail, Moon, Wakeman family: Jemma, Oliver, Rachel, Rick, Hackett family: Jo, John, Steve, Enter an age to search for 53 Searching for all people of age 53: Frank Zappa, Rachel Wakeman, Enter an age to search for 29 Searching for all people of age 29: Virgil Howe, Dweezil Zappa, Jemma Wakeman, Enter an age to search tor: Searching for all people of age 57: Janet Howe, Rick Wakeman, Enter an age to search for 54 Searching for all people of age 54: Enter an age to search for 0 Largest is the Howe family: Dylan,Georgia, Janet, Steve, Virgil, Smallest is the Underwood family: Ian, Ruth, Your output does not have to be formatted like mine but should match these results. If you have trailing commas, like mine, don’t worry about it. After getting your program working, run it on the second input file and search for people whose ages are 39, 42, 61, 10, 16 and 8. Submit your commented code and the output from running the program on the second input file
Expert Answer
Answer to C Programming Problem // I would really appreciate some help with this assignment please You can do the testing of the p… . . .
OR

