Answer to Question #273338 in C for Mr Z

Question #273338

92) Fix the Error

typedef struct
{
int day;
int month;
int year;
} date_t;
typedef struct
{
char surname[20];
char forename[20];
date_t  birthday;
} person_t;
int main() {
person_t    person[MAX_ENTRIES];
inentry;
for (entry = 0; entry < MAX_ENTRIES; entry++)
{
printf("\n\nRecord %d:\n", entry);
printf("Enter the surname: ");
scanf("%s", person[entry].surname);

scanf("%s", person[entry].forename);

scanf("%d", &person[entry].birthday.day);

scanf("%d", &person[entry].birthday.month);

scanf("%d", &person[entry].birthday.year);
printf("Enter an index between 0 and %d: ", MAX_ENTRIES - 1);
scanf("%d", &entry);                
printf("Surname: %s\n", person[entry].surname);
printf("Forename: %s\n", person[entry].forename);
printf("Date of birth: %02d/%02d/%04d\n\n\n",











1
Expert's answer
2021-11-30T00:37:15-0500
#include<stdio.h>
const int MAX_ENTRIES = 50;
typedef struct
{
int day;
int month;
int year;
} date_t;
typedef struct
{
char surname[20];
char forename[20];
date_t  birthday;
} person_t;
int main() {
person_t    person[MAX_ENTRIES];
int entry;
for (entry = 0; entry < MAX_ENTRIES; entry++)
{
printf("\n\nRecord %d:\n", entry);
printf("Enter the surname: ");
scanf("%s", person[entry].surname);


scanf("%s", person[entry].forename);


scanf("%d", &person[entry].birthday.day);


scanf("%d", &person[entry].birthday.month);


scanf("%d", &person[entry].birthday.year);
printf("Enter an index between 0 and %d: ", MAX_ENTRIES - 1);
scanf("%d", &entry);                
printf("Surname: %s\n", person[entry].surname);
printf("Forename: %s\n", person[entry].forename);
printf("Date of birth: %02d/%02d/%04d\n\n\n",person[entry].birthday.day,person[entry].birthday.month,person[entry].birthday.year);
}}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS