Who's Older Code in C language #include #include "person.h" Day get_date(void); int older(Person *p1, Person *p2); int main() {   Person p1, p2;   p1.name = "Jay Vince";   p2.name = "Faith";   p1.bday = get_date();   p2.bday = get_date();      int old = older(&p1, &p2);   if (old == -1) {     printf("%s is older", p1.name);   } else if (old == 1) {     printf("%s is older", p2.name);   } else {     printf("Both are the same");   }      return 0; } Day get_date() {   printf("Enter the month (Jan=1, ..., Dec=12): ");   Month month;   scanf("%d", &month);      printf("Enter the day: ");   int date;   scanf("%d", &date);      printf("Enter the year: ");   int year;   scanf("%d", &year);      Day today = { month, date, year};   return today; } // Returns -1 is p1 is older, 1 is p2 is older, 0 if both the same age int older(Person *p1, Person *p2) {      return 0; }   refer to pic for instructions

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

Who's Older

Code in C language

#include <stdio.h>
#include "person.h"

Day get_date(void);
int older(Person *p1, Person *p2);

int main() {
  Person p1, p2;
  p1.name = "Jay Vince";
  p2.name = "Faith";
  p1.bday = get_date();
  p2.bday = get_date();
  
  int old = older(&p1, &p2);
  if (old == -1) {
    printf("%s is older", p1.name);
  } else if (old == 1) {
    printf("%s is older", p2.name);
  } else {
    printf("Both are the same");
  }
  
  return 0;
}

Day get_date() {
  printf("Enter the month (Jan=1, ..., Dec=12): ");
  Month month;
  scanf("%d", &month);
  
  printf("Enter the day: ");
  int date;
  scanf("%d", &date);
  
  printf("Enter the year: ");
  int year;
  scanf("%d", &year);
  
  Day today = { month, date, year};
  return today;
}

// Returns -1 is p1 is older, 1 is p2 is older, 0 if both the same age
int older(Person *p1, Person *p2) {
  
  return 0;
}

 

refer to pic for instructions

main.c
person.h x
day.h
>
+ c
1. Who's Older
#include "day.h"
by Jay Vince Serato
3 - typedef struct {
Given two persons and their birthdays, identify if who is the
4.
char* name;
Day bday;
6 } Person;|
5
older person by completing the older method.
The older method will have the following return values:
• -1 if p1 is older
• 1if p2 is older
• O if both ages are equal
Input
1. Person 1's Month
2. Person 1's Day
3. Person 1's Year
4. Person 2's Month
5. Person 2's Day
6. Person 2's Year
Output
Faith is older
Transcribed Image Text:main.c person.h x day.h > + c 1. Who's Older #include "day.h" by Jay Vince Serato 3 - typedef struct { Given two persons and their birthdays, identify if who is the 4. char* name; Day bday; 6 } Person;| 5 older person by completing the older method. The older method will have the following return values: • -1 if p1 is older • 1if p2 is older • O if both ages are equal Input 1. Person 1's Month 2. Person 1's Day 3. Person 1's Year 4. Person 2's Month 5. Person 2's Day 6. Person 2's Year Output Faith is older
main.c
person.h
day.h x
+ c
1. Who's Older
typedef enum {JAN
2- typedef struct {
Month mon;
1
1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC} Month;
by Jay Vince Serato
3
int day;
int year;
6 } Day;
Given two persons and their birthdays, identify if who is the
older person by completing the older method.
The older method will have the following return values:
• -1 if p1 is older
• 1 if p2 is older
• O if both ages are equal
Input
1. Person 1's Month
2. Person 1's Day
3. Person 1's Year
4. Person 2's Month
5. Person 2's Day
6. Person 2's Year
Output
Faith is older
Transcribed Image Text:main.c person.h day.h x + c 1. Who's Older typedef enum {JAN 2- typedef struct { Month mon; 1 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC} Month; by Jay Vince Serato 3 int day; int year; 6 } Day; Given two persons and their birthdays, identify if who is the older person by completing the older method. The older method will have the following return values: • -1 if p1 is older • 1 if p2 is older • O if both ages are equal Input 1. Person 1's Month 2. Person 1's Day 3. Person 1's Year 4. Person 2's Month 5. Person 2's Day 6. Person 2's Year Output Faith is older
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