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 character value for its gender. Furthermore, you are...






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 character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main() function, there's a pre-created array of 5 Persons.

  2. Your task is to ask the user for the values of the age and gender of these Persons.

  3. Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one.






Input



1. A series of ages and genders of the 5 Persons


Source Code:


#include


typedef struct {
    int age;
    char gender;
} Person;


void displayPerson(Person);


int main(void) {
    Person persons[5];



    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");
    }
    printf("\n\n");
}




Output<br>Person 1<br>Enter Person's age: 24<br>Enter Person's gender: M<br>Person 2<br>Enter Person's age: 21<br>Enter Person's gender: F<br>Person 3<br>Enter Person's age: 22<br>Enter Person's gender: F<br>Person 4<br>Enter Person's age: 60<br>Enter Person's gender: F<br>Person 5<br>Enter Person's age: 64<br>Enter Person 's gender: M<br>PERSON DETAILS:<br>Age: 24<br>Gender: Male<br>PERSON DETAILS:<br>Age: 21<br>Gender: Female<br>PERSON DETAILS:<br>Age: 22<br>Gender: Female<br>PERSON DETAILS:<br>Age: 6e<br>Gender: Female<br>PERSON DETAILS:<br>Age: 64<br>Gender: Male<br>

Extracted text: Output Person 1 Enter Person's age: 24 Enter Person's gender: M Person 2 Enter Person's age: 21 Enter Person's gender: F Person 3 Enter Person's age: 22 Enter Person's gender: F Person 4 Enter Person's age: 60 Enter Person's gender: F Person 5 Enter Person's age: 64 Enter Person 's gender: M PERSON DETAILS: Age: 24 Gender: Male PERSON DETAILS: Age: 21 Gender: Female PERSON DETAILS: Age: 22 Gender: Female PERSON DETAILS: Age: 6e Gender: Female PERSON DETAILS: Age: 64 Gender: Male

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here