(C PROGRAMMING ONLY!) 3. Pet Lover by CodeChum Admin One of the easiest ways to make a pet lover happy is to give them very many pets!   My friend, Jhelian is a pet lover and for her 21st birthday, I'm planning to give her very many Dogs. It's very timely because my pet dog just gave birth to a lot of cuties!   So I don't really need to buy. All I need is to just give these cute little fur babies to her.   Instructions: In the code editor, you are provided with the definition of a struct Dog. This struct needs a character value for its gender, which could either be 'm' for a male Dog or 'f' for a female Dog. Furthermore, an array of Dogs has already been created an each of their genders has been set. Then, on line 16, a call to the function giveDogs() was made where the dogs array was passed. Your task is to implement this giveDogs() function which has the following details: Return type - void Name - giveDogs Parameters a pointer/holder of a Dogs array size of the Dogs array Description - loops through the Dogs array and prints the correct message (refer to the sample output) Output Note that the dog number starts at 1, not 0. Dog #1 (gender = m) Dog #2 (gender = f) Dog #3 (gender = m) Dog #4 (gender = f) Dog #5 (gender = m) Dog #6 (gender = f) Dog #7 (gender = m) Dog #8 (gender = f) Dog #9 (gender = m) Dog #10 (gender = f) Dog #11 (gender = m) Dog #12 (gender = f) Dog #13 (gender = m)

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

(C PROGRAMMING ONLY!)

3. Pet Lover
by CodeChum Admin

One of the easiest ways to make a pet lover happy is to give them very many pets!

 

My friend, Jhelian is a pet lover and for her 21st birthday, I'm planning to give her very many Dogs. It's very timely because my pet dog just gave birth to a lot of cuties!

 

So I don't really need to buy. All I need is to just give these cute little fur babies to her.

 

Instructions:

In the code editor, you are provided with the definition of a struct Dog. This struct needs a character value for its gender, which could either be 'm' for a male Dog or 'f' for a female Dog.
Furthermore, an array of Dogs has already been created an each of their genders has been set. Then, on line 16, a call to the function giveDogs() was made where the dogs array was passed.
Your task is to implement this giveDogs() function which has the following details:
Return type - void
Name - giveDogs
Parameters
a pointer/holder of a Dogs array
size of the Dogs array
Description - loops through the Dogs array and prints the correct message (refer to the sample output)
Output

Note that the dog number starts at 1, not 0.

Dog #1 (gender = m)
Dog #2 (gender = f)
Dog #3 (gender = m)
Dog #4 (gender = f)
Dog #5 (gender = m)
Dog #6 (gender = f)
Dog #7 (gender = m)
Dog #8 (gender = f)
Dog #9 (gender = m)
Dog #10 (gender = f)
Dog #11 (gender = m)
Dog #12 (gender = f)
Dog #13 (gender = m)
.
.
.

Dog #3
(gender
Dog #4 (gender =
f)
main.c
く
<>
+ c
Dog #5 (gender
= m)
1 #include<stdio.h>
Dog #6 (gender = f)
2
Dog #7 (gender = m)
3 typedef struct {
char gender;
Dog #8 (gender = f)
4
Dog #9 (gender = m)
5 } Dog;
Dog #10 (gender = f)
7 void giveDogs(Dog*, int);
Dog #11 (gender = m)
8
Dog #12 (gender = f)
9 int main(void) {
Dog dogs[100];
Dog #13 (gender = m)
10
11
for(int i
dogs[i].gender = i % 2 == 0 ? 'm' : 'f';
}
12
= 0; i < 100; i++) {
13
15
giveDogs (dogs, 100);
16
17
O O H N m4
Transcribed Image Text:Dog #3 (gender Dog #4 (gender = f) main.c く <> + c Dog #5 (gender = m) 1 #include<stdio.h> Dog #6 (gender = f) 2 Dog #7 (gender = m) 3 typedef struct { char gender; Dog #8 (gender = f) 4 Dog #9 (gender = m) 5 } Dog; Dog #10 (gender = f) 7 void giveDogs(Dog*, int); Dog #11 (gender = m) 8 Dog #12 (gender = f) 9 int main(void) { Dog dogs[100]; Dog #13 (gender = m) 10 11 for(int i dogs[i].gender = i % 2 == 0 ? 'm' : 'f'; } 12 = 0; i < 100; i++) { 13 15 giveDogs (dogs, 100); 16 17 O O H N m4
main.c
<>
+ c
4
char gender;
5 } Dog;
7 void giveDogs (Dog*, int);
8
9 int main(void) {
Dog dogs[100];
10
11
for(int i = 0; i < 100; i++) {
dogs[i].gender = i % 2
}
12
13
== 0 ? 'm' : 'f';
14
15
giveDogs (dogs, 100);
16
17
18
return 0;
19 }
20
21 void giveDogs(Dog *dogs, int size) {
// TODO: Implement this
22
23 }
Transcribed Image Text:main.c <> + c 4 char gender; 5 } Dog; 7 void giveDogs (Dog*, int); 8 9 int main(void) { Dog dogs[100]; 10 11 for(int i = 0; i < 100; i++) { dogs[i].gender = i % 2 } 12 13 == 0 ? 'm' : 'f'; 14 15 giveDogs (dogs, 100); 16 17 18 return 0; 19 } 20 21 void giveDogs(Dog *dogs, int size) { // TODO: Implement this 22 23 }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 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