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

This assignment must be done in C only! No C++ or any other C variation allowed!

ID: 3536541 • Letter: T

Question

This assignment must be done in C only! No C++ or any other C variation allowed!


typedef struct {
   char firstName[30];
   char lastName[30];
   char street[35];
   char city[20];
   char state[3];
   int zip;
   char phone[15];
   int accountId;
} Customer;

You can assume that the user always enters proper data - no input validation is required. Also all the strings are words without spaces, i.e you are expected to read the string using scanf("%s") and not gets or fgets

Sample Output

Sample (user input in blue, program output in magenta)

Enter Data for Customer 0
Enter First Last Phone: Doug Oregon 123-456-7890
Enter Address (Street City State ZIP): Main Portland OR 12345


Enter Data for Customer 1
Enter First Last Phone: Doug Washington 123-456-7890
Enter Address (Street City State ZIP): Main Portland WA 12345


Enter Data for Customer 2
Enter First Last Phone: Doug California 123-456-7890
Enter Address (Street City State ZIP): Main Portland CA 12345


Enter Data for Customer 3
Enter First Last Phone: Doug Nevada 123-456-7890
Enter Address (Street City State ZIP): Main Portland NV 12345


Enter Data for Customer 4
Enter First Last Phone: Doug Colorado 123-456-7890
Enter Address (Street City State ZIP): Main Portland CO 12345


Enter Data for Customer 5
Enter First Last Phone: Another Colorado 123-456-7890
Enter Address (Street City State ZIP): Main Portland CO 12345


Enter Data for Customer 6
Enter First Last Phone: Doug Arizona 123-456-7890
Enter Address (Street City State ZIP): Main Portland AZ 12345


Enter Data for Customer 7
Enter First Last Phone: Doug Florida 123-456-7890
Enter Address (Street City State ZIP): Main Portland FL 12345


Enter Data for Customer 8
Enter First Last Phone: Doug Georgia 123-456-7890
Enter Address (Street City State ZIP): Main Portland GA 12345


Enter Data for Customer 9
Enter First Last Phone: Doug Jones 123-456-7890
Enter Address (Street City State ZIP): Main Portland CO 12345


Enter 2-character state code: CO
Data for Customer 4
Account: 4
Name: Doug Colorado
Addr: Main Portland CO 12345
Phone: 123-456-7890


Data for Customer 5
Account: 5
Name: Another Colorado
Addr: Main Portland CO 12345
Phone: 123-456-7890


Data for Customer 9
Account: 9
Name: Doug Jones
Addr: Main Portland CO 12345
Phone: 123-456-7890

Explanation / Answer

#include<stdio.h>


struct customer


{


char firstName[30];

char lastName[30];

char street[35];

char city[20];

char state[3];

int zip;

int phone;

int accountId;


};


void main()


{


customer a[10];


int i;


for(i=0;i<10;i++)


{


printf("Enter Data for Customer %d Enter First Last Phone ");


scanf("%s%s%d",&a[i].firstname,&a[i].lastname,&a[i].phone);


printf(" Enter Address (Street City State ZIP) ");


scanf("%s%s%s%d",&a[i].street,&a[i].city,&a[i].state,&a[i].zip);


a[i].accountid=i;


}




printf("enter the state code ");


char s[3];


scanf("%s",&s);


for(i=0;i<10;i++)


{


if(a[i].state==s)


{


printf(" Data for Customer %d Account: %d Name %s %s Addr: %s%s%s%d Phone %d",i,a[i].accountid,a[i].firstname,a[i].lastname,a[i].street,a[i].city,a[i].state,a[i].zip,a[i].phone);


}


}


}

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