Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

< C programming> Structures This assignment focuses on using struct structures. Instructions Create a program called structs.c that does the following: Create an array that

< C programming>

Structures

This assignment focuses on using struct structures.

Instructions

Create a program called structs.c that does the following:

Create an array that contains ten (10) variables of the following type:

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;

Prompt the user for values for each of the variables in each structure, i.e. you will be asking for 10 firstName values, 10 lastName values, and so forth. HINT: Loops...

After all of the values for the structure variables have been input, you need to prompt the user for a state string, and then display the values of all variables in each structure where the state string matches the user's input.Use functions if you feel comfortable but are not mandatory for this assignment.

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

=+j Explain the essential nature of repatriation.

Answered: 1 week ago