(C PROGRAMMING ONLY) 4. Bored Person by CodeChum Admin Help! Our people in this tech universe we created are starting to get really, really boreed!   They're complaining because there's internet connection but they don't have mobile phones. We need to create one for them ASAP or else they will go crazy!!     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 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)

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
100%

(C PROGRAMMING ONLY)

4. Bored Person
by CodeChum Admin

Help! Our people in this tech universe we created are starting to get really, really boreed!

 

They're complaining because there's internet connection but they don't have mobile phones. We need to create one for them ASAP or else they will go crazy!!

 

 

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

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)

main.c
1 #include<stdio.h>
2
3 typedef struct {
4
int age;
5
char gender;
6
Phone phone;
7 } Person;
8
9 void display Person (Person);
10
11 int main(void) {
12
13
14
return 0;
15 }
16
17 void displayPerson (Person p) {
18
19
printf("PERSON DETAILS: \n");
printf("Age: %d\n", p.age);
printf("Gender: ");
20
21
if(p.gender
==
'M') {
22
printf("Male");
23
} else {
+ c
4
Transcribed Image Text:main.c 1 #include<stdio.h> 2 3 typedef struct { 4 int age; 5 char gender; 6 Phone phone; 7 } Person; 8 9 void display Person (Person); 10 11 int main(void) { 12 13 14 return 0; 15 } 16 17 void displayPerson (Person p) { 18 19 printf("PERSON DETAILS: \n"); printf("Age: %d\n", p.age); printf("Gender: "); 20 21 if(p.gender == 'M') { 22 printf("Male"); 23 } else { + c 4
<> + C
13
14
return 0;
15 }
16
17 void display Person (Person p) {
18
printf("PERSON DETAILS: \n");
19
20
printf("Age: %d\n", p.age);
printf("Gender: ");
if(p.gender == 'M') {
printf("Male");
21
22
23
} else {
24
printf("Female");
25
}
26
printf("\n");
27
28
29
printf("Phone: ");
if(p.phone.type == 'I') {
printf("iPhone");
30
31
} else {
32
printf("Android");
33
}
34
printf(" (%dGB, %dGB)", p.phone.ram, p.phone.storage);
35}
main.c
4
Transcribed Image Text:<> + C 13 14 return 0; 15 } 16 17 void display Person (Person p) { 18 printf("PERSON DETAILS: \n"); 19 20 printf("Age: %d\n", p.age); printf("Gender: "); if(p.gender == 'M') { printf("Male"); 21 22 23 } else { 24 printf("Female"); 25 } 26 printf("\n"); 27 28 29 printf("Phone: "); if(p.phone.type == 'I') { printf("iPhone"); 30 31 } else { 32 printf("Android"); 33 } 34 printf(" (%dGB, %dGB)", p.phone.ram, p.phone.storage); 35} main.c 4
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
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