Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and a character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main(), there are two Persons already created: one Male Person and one Female Person. Your task is to first ask the user for the age of the Male Person and the age of the Female Person. Then, define and declare a function called createKidPerson() which has the following definition: Return type - Person Name - createKidPerson Parameters Person father - the father of the kid to be created Person mother - the mother of the kid to be created Description - creates a new Person and returns this. The age of this Person will be set to 1 while its gender will be set based on the rules mentioned above. Finally, create a new Person and call this createKidPerson() in the main and then pass this newly created Person in the displayPerson() function. #include typedef struct { int age; char gender; } Person; void displayPerson(Person); int main(void) { Person father; Person mother; father.gender = 'M'; mother.gender = 'F'; return 0; } void displayPerson(Person p) { printf("PERSON DETAILS:\n"); printf("Age: %d\n", p.age); printf("Gender: "); if(p.gender == 'M') { printf("Male"); } else { printf("Female"); } }
Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and a character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main(), there are two Persons already created: one Male Person and one Female Person. Your task is to first ask the user for the age of the Male Person and the age of the Female Person. Then, define and declare a function called createKidPerson() which has the following definition: Return type - Person Name - createKidPerson Parameters Person father - the father of the kid to be created Person mother - the mother of the kid to be created Description - creates a new Person and returns this. The age of this Person will be set to 1 while its gender will be set based on the rules mentioned above. Finally, create a new Person and call this createKidPerson() in the main and then pass this newly created Person in the displayPerson() function. #include typedef struct { int age; char gender; } Person; void displayPerson(Person); int main(void) { Person father; Person mother; father.gender = 'M'; mother.gender = 'F'; return 0; } void displayPerson(Person p) { printf("PERSON DETAILS:\n"); printf("Age: %d\n", p.age); printf("Gender: "); if(p.gender == 'M') { printf("Male"); } else { printf("Female"); } }
Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
Related questions
Question
Instructions:
- In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and a character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main(), there are two Persons already created: one Male Person and one Female Person.
- Your task is to first ask the user for the age of the Male Person and the age of the Female Person.
- Then, define and declare a function called createKidPerson() which has the following definition:
- Return type - Person
- Name - createKidPerson
-
Parameters
- Person father - the father of the kid to be created
- Person mother - the mother of the kid to be created
- Description - creates a new Person and returns this. The age of this Person will be set to 1 while its gender will be set based on the rules mentioned above.
- Finally, create a new Person and call this createKidPerson() in the main and then pass this newly created Person in the displayPerson() function.
#include<stdio.h>
typedef struct {
int age;
char gender;
} Person;
void displayPerson(Person);
int main(void) {
Person father;
Person mother;
father.gender = 'M';
mother.gender = 'F';
return 0;
}
void displayPerson(Person p) {
printf("PERSON DETAILS:\n");
printf("Age: %d\n", p.age);
printf("Gender: ");
if(p.gender == 'M') {
printf("Male");
} else {
printf("Female");
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage