Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c source code: I) Create a struct Person with attributes char name[20], int age, double score. Use typedef such that you can refer to
In c source code:
I) Create a struct Person with attributes char name[20], int age, double score. Use typedef such that you can refer to "struct Person" using "Person". You may assume that no Person has a name longer than 19 chars, i.e., it will fit into the array of length 20. II) Write a function "Person create Person(char name[], int age,double score) that returns a person with attributes as specified by the inputs. Remember that you have to use a string function to copy over the "name" to the the Person.) III) Write a function void printPerson(Person p) that prints the attributes of the Person p to the screen. Print the attributes using printf and the format string "%s %d %d ", i.e., printf("%s %d %d ", ...). Ex. Name age score IV) Write a function void changeAge(Person * p,int newAge) that changes the age of a person to new age. V) Create an "void print People Person people[], int length)" function that prints the people stored in an array to screen. "length is the number of people that are initialized in the array. The function prototypes and a sample main are provided below: Person create Person(char name[],int age, double score); void printPerson(Person p); void change Age Person * p,int new Age); void print People Person people[],int length); void main(){ Person p = create Person ("Rickard",31,100); printPerson(p); change Age(&p,30); printPerson(p); Person people[3]; people[0] = createPerson("John",22,83); people[1] = createPerson("Danny",24,63); people[2] = create Person ("Marry",20,81); printPeople(people,3)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started