Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age, character value for its gender, and a struct Phone for its phone. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. Your task is to define a new struct called Phone. This Phone would need 3 properties: char type - which can either be 'I' for iPhone or 'A' for Android int ram - the number of RAM this phone has int storage - the number of storage this phone has Then, using this struct Phone you defined, create a Phone in the main() and ask the user for its type, ram, and storage. Next, create a struct Person and ask the user for its age and gender and then set its phone to the Phone you just created earlier. Finally, call the displayPerson() function and pass the Person. Input 1. The type of the Phone 2. The RAM of the Phone 3. The storage of the Phone 4. The age of the Person 5. The gender of the Person   Source Code: #include typedef struct {     int age;     char gender;     Phone phone; } Person; void displayPerson(Person); int main(void) {     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");     printf("Phone: ");     if(p.phone.type == 'I') {         printf("iPhone");     } else {         printf("Android");     }     printf(" (%dGB, %dGB)", p.phone.ram, p.phone.storage); }

Enhanced Discovering Computers 2017 (Shelly Cashman Series) (MindTap Course List)
1st Edition
ISBN:9781305657458
Author:Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Publisher:Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Chapter7: Input And Output: Extending Capabilities Of Computers And Mobile Devices
Section: Chapter Questions
Problem 11TF
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, character value for its gender, and a struct Phone for its phone. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter.
  2. Your task is to define a new struct called Phone. This Phone would need 3 properties:
    1. char type - which can either be 'I' for iPhone or 'A' for Android
    2. int ram - the number of RAM this phone has
    3. int storage - the number of storage this phone has
  3. Then, using this struct Phone you defined, create a Phone in the main() and ask the user for its type, ram, and storage.
  4. Next, create a struct Person and ask the user for its age and gender and then set its phone to the Phone you just created earlier.
  5. Finally, call the displayPerson() function and pass the Person.

Input

1. The type of the Phone

2. The RAM of the Phone

3. The storage of the Phone

4. The age of the Person

5. The gender of the Person

 

Source Code:

#include<stdio.h>

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

void displayPerson(Person);

int main(void) {


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

    printf("Phone: ");
    if(p.phone.type == 'I') {
        printf("iPhone");
    } else {
        printf("Android");
    }
    printf(" (%dGB, %dGB)", p.phone.ram, p.phone.storage);
}

Output
Enter Phone's type: I
Enter Phone's RAM: 2
Enter Phone's storage: 124
Enter Person's age: 24
Enter Person's gender: M
PERSON DETAILS:
Age: 24
Gender: Male
Phone: iPhone (2GB, 124GB)
Transcribed Image Text:Output Enter Phone's type: I Enter Phone's RAM: 2 Enter Phone's storage: 124 Enter Person's age: 24 Enter Person's gender: M PERSON DETAILS: Age: 24 Gender: Male Phone: iPhone (2GB, 124GB)
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Reference Types in Function
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
Recommended textbooks for you
Enhanced Discovering Computers 2017 (Shelly Cashm…
Enhanced Discovering Computers 2017 (Shelly Cashm…
Computer Science
ISBN:
9781305657458
Author:
Misty E. Vermaat, Susan L. Sebok, Steven M. Freund, Mark Frydenberg, Jennifer T. Campbell
Publisher:
Cengage Learning
Microsoft Windows 10 Comprehensive 2019
Microsoft Windows 10 Comprehensive 2019
Computer Science
ISBN:
9780357392607
Author:
FREUND
Publisher:
Cengage
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781305971776
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L