Create a program in C language that is an example of an array of structs. It wil
ID: 3821766 • Letter: C
Question
Create a program in C language that is an example of an array of structs.
It will show -->> First_name, Last_name
Address,
city, state, zip code
I started the program off like this.. continue program to have the output show like the picture.
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef struct{
int id;
char First_name[10];
char Last_name[10];
char address[20];
char city[10];
char state[3];
char zip[6];
} Aperson;
John Summers 678 S Morland St California, CA 90012
Explanation / Answer
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef struct{
int id;
char First_name[10];
char Last_name[10];
char address[20];
char city[10];
char state[3];
char zip[6];
} Aperson;
int main()
{
Aperson a;
strcpy(a.First_name,"John");
strcpy(a.Last_name,"Summers");
strcpy(a.address,"678 S Morland st");
strcpy(a.city,"California ");
strcpy(a.state,"CA");
strcpy(a.zip,"90012");
printf("%s %s ",a.First_name,a.Last_name);
printf("%s ",a.address);
printf("%s, %s %s",a.city,a.state,a.zip);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.