Code using c++ 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. Note: The code should call `createKidPerson` in main. Curent Code: #include using namespace std; 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) {     cout << "PERSON DETAILS:" << endl;     cout << "Age: " << p.age << endl;     cout << "Gender: ";     if(p.gender == 'M') {         cout << "Male";     } else {         cout << "Female";     } } Input 1. The age of the Male Person 2. The age of the Female Person 1st Output Enter·the·Male·Person's·age:·24 Enter·the·Female·Person's·age:·21   PERSON·DETAILS: Age:·1 Gender:·Male   2nd Ouput Enter the Male Person's age: 21 Enter the Female Person's age: 24   PERSON DETAILS: Age: 1 Gender: Female

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

Code using c++

Instructions:

  1. 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.
  2. Your task is to first ask the user for the age of the Male Person and the age of the Female Person.
  3. Then, define and declare a function called createKidPerson() which has the following definition:
    1. Return type - Person
    2. Name - createKidPerson
    3. Parameters
      1. Person father - the father of the kid to be created
      2. Person mother - the mother of the kid to be created
    4. 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.
  4. Finally, create a new Person and call this createKidPerson() in the main and then pass this newly created Person in the displayPerson() function.

    Note: The code should call `createKidPerson` in main.

    Curent Code:

    #include <iostream>
    using namespace std;

    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) {
        cout << "PERSON DETAILS:" << endl;
        cout << "Age: " << p.age << endl;
        cout << "Gender: ";
        if(p.gender == 'M') {
            cout << "Male";
        } else {
            cout << "Female";
        }
    }

    Input

    1. The age of the Male Person

    2. The age of the Female Person

    1st Output

    Enter·the·Male·Person's·age:·24
    Enter·the·Female·Person's·age:·21
     
    PERSON·DETAILS:
    Age:·1
    Gender:·Male
     
    2nd Ouput
    Enter the Male Person's age: 21
    Enter the Female Person's age: 24
     
    PERSON DETAILS:
    Age: 1
    Gender: Female
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
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