(C PROGRAMMING ONLY) 5. Making a Kid From Two Persons by CodeChum Admin `The population is slowly decreasing!   It's now time to enable these Persons to create their own. But we need to be careful. The overall gender distribution of the Persons should always be maintained (i.e. the Male should be nearly equal as the female) so that gender equality can be easier to maintain.   Here is the guide in determining the gender of the newly created Person: If the father is older than the mother, then the child is Male If the mother is older than the father, then the child is Female If the father's age is equal to the mother's age and the age is even, then the child is Male If the father's age is equal to the mother's age and the age is odd, then the child is Female What are you waiting for, let's settle this problem once and for all!     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. Input 1. The age of the Male Person 2. The age of the Female Person       Output Enter the Male Person's age: 24 Enter the Female Person's age: 21 PERSON DETAILS: Age: 1 Gender: Male

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(C PROGRAMMING ONLY)

5. Making a Kid From Two Persons
by CodeChum Admin

`The population is slowly decreasing!

 

It's now time to enable these Persons to create their own. But we need to be careful. The overall gender distribution of the Persons should always be maintained (i.e. the Male should be nearly equal as the female) so that gender equality can be easier to maintain.

 

Here is the guide in determining the gender of the newly created Person:

If the father is older than the mother, then the child is Male
If the mother is older than the father, then the child is Female
If the father's age is equal to the mother's age and the age is even, then the child is Male
If the father's age is equal to the mother's age and the age is odd, then the child is Female


What are you waiting for, let's settle this problem once and for all!

 

 

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.
Input

1. The age of the Male Person

2. The age of the Female Person

 

 

 

Output

Enter the Male Person's age: 24
Enter the Female Person's age: 21

PERSON DETAILS:
Age: 1
Gender: Male

main.c
10 int main(void) {
11
12
Person father;
13
Person mother;
14
15
father.gender = 'M';
mother.gender = 'F';
16
17
18
19
20
return 0;
21 }
22
24
25
23 void display Person (Person p) {
printf("PERSON DETAILS: \n");
printf("Age: %d\n", p.age);
printf("Gender: ");
if(p.gender == 'M') {
printf("Male");
26
27
28
29
} else {
30
printf("Female");
31
}
32 }
<
> + C
Transcribed Image Text:main.c 10 int main(void) { 11 12 Person father; 13 Person mother; 14 15 father.gender = 'M'; mother.gender = 'F'; 16 17 18 19 20 return 0; 21 } 22 24 25 23 void display Person (Person p) { printf("PERSON DETAILS: \n"); printf("Age: %d\n", p.age); printf("Gender: "); if(p.gender == 'M') { printf("Male"); 26 27 28 29 } else { 30 printf("Female"); 31 } 32 } < > + C
main.c
1 #include<stdio.h>
2
3 typedef struct {
4
int age;
5
char gender;
6} Person;
7
8 void display Person (Person);
9
10 int main(void) {
11
12
Person father;
13
Person mother;
14
15
father.gender = 'M';
mother.gender = 'F';
16
17
18
19
20
return 0;
21 }
22
23 void displayPerson (Person p) {
<
+ c
▶
Transcribed Image Text:main.c 1 #include<stdio.h> 2 3 typedef struct { 4 int age; 5 char gender; 6} Person; 7 8 void display Person (Person); 9 10 int main(void) { 11 12 Person father; 13 Person mother; 14 15 father.gender = 'M'; mother.gender = 'F'; 16 17 18 19 20 return 0; 21 } 22 23 void displayPerson (Person p) { < + c ▶
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY