Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that creates a structure template with two members according to

ID: 3621377 • Letter: W

Question

Write a program that creates a structure template with two members according to the following criteria:
a. The first member is a social security number. The second number is a structure with three members. Its first member contains a first name, its second member contains a middle name, and its final number conatians a last name. Create and initialize an array of five such structures. Have the program print the data in this format:
Dribble; Flossie M. -- 302039823

Only the initial letter of the middle name is printed, and a period is added. Neither the initial (of course) nor the period should be printed if the middle name member is empty. Write a function to the the printing; pass the structure array to the function.

b. Modify par "a" by passing the structure value instead of the address.

Explanation / Answer

please rate - thanks

#include<stdio.h>
#include<conio.h>
struct NAME
   {char first[10];
    char middle[10];
    char last[15];
};
struct PERSON
   {char SSN[10];
   struct NAME name;
};
void printpeople(struct PERSON[],int);
int main()
{int i,n=5;
struct PERSON people[5];
for(i=0;i<n;i++)
{printf("For person number %d ",i+1);
printf("Enter social security number(numbers only): ");
scanf("%s",&people[i].SSN);
printf("Enter First name: ");
scanf("%s",&people[i].name.first);
printf("Enter Middle name (- if none): ");
scanf("%s",&people[i].name.middle);
printf("Enter Last name: ");
scanf("%s",&people[i].name.last);
}
printpeople(people,n);
getch();
return 0;
}
void printpeople(struct PERSON p[],int n)
{int i;
printf("The people are: ");
for(i=0;i<n;i++)
if(p[i].name.middle[0]=='-')
     printf("%s; %s --%s ",p[i].name.last,p[i].name.first,p[i].SSN);
else
    printf("%s; %s %c.--%s ",p[i].name.last,p[i].name.first,p[i].name.middle[0],p[i].SSN);
}

---------------------------------

#include<stdio.h>
#include<conio.h>
struct NAME
   {char first[10];
    char middle[10];
    char last[15];
};
struct PERSON
   {char SSN[10];
   struct NAME name;
};
void printpeople(struct PERSON*,int);
int main()
{int i,n=5;
struct PERSON people[5];
for(i=0;i<n;i++)
{printf("For person number %d ",i+1);
printf("Enter social security number(numbers only): ");
scanf("%s",&people[i].SSN);
printf("Enter First name: ");
scanf("%s",&people[i].name.first);
printf("Enter Middle name (- if none): ");
scanf("%s",&people[i].name.middle);
printf("Enter Last name: ");
scanf("%s",&people[i].name.last);
}
printpeople(people,n);
getch();
return 0;
}
void printpeople(struct PERSON *p,int n)
{int i;
printf("The people are: ");
for(i=0;i<n;i++)
if(p[i].name.middle[0]=='-')
     printf("%s; %s --%s ",p[i].name.last,p[i].name.first,p[i].SSN);
else
    printf("%s; %s %c.--%s ",p[i].name.last,p[i].name.first,p[i].name.middle[0],p[i].SSN);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote