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");     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

#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");
    }
}

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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Passing Array as Argument
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education