hello, i cant get the expected output. below is my code
#includetypedef struct{ int age; char gender;} Person;void displayPerson(Person);int main(void){ Person persons[5]; for(int i=0;i<> { printf("Person #%d\n",i+1); printf("Enter Person's age: "); scanf("%d",&persons[i].age); printf("Enter Person's gender: "); scanf("%c",&persons[i].gender); } for(int i=0;i<> displayPerson(persons[i]); 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 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.Your task is to ask the user for the values of the age and gender of these Persons.Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one.Input1. A series of ages and genders of the 5 PersonsExtracted text: Input 1. A series of ages and genders of the 5 Persons Cutput 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 a Enter Person's age: 22 Enter Person's gender: F Person 4 Enter Person's age: he Enter Person's gender: F Person 5 Enter Person's age: 54 Enter Person's gender: M PERSON DETAILS: Age: 24 Gender: Male PERSON DETALS: Age 21 Gender: Fenale PERSON DETALLS: Age: 22 Gender: Fenale PERSON DETALS: Age: 60 Gender: Fenale PERSON DETALSI Age: 64 Gender: Male
void displayPerson(Person);
int main(void){ Person persons[5]; for(int i=0;i<> { printf("Person #%d\n",i+1); printf("Enter Person's age: "); scanf("%d",&persons[i].age); printf("Enter Person's gender: "); scanf("%c",&persons[i].gender); } for(int i=0;i<> displayPerson(persons[i]);
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:
Input
1. A series of ages and genders of the 5 Persons
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here