Purchase Solution

Using C Structure to store contact information

Not what you're looking for?

Ask Custom Question

Write a C program that prompts the user to enter some information about up to ten individuals. It should store this information in a structure. The program should obtain the information from the structure, and output it as shown in attachment. Please see the attachment for complete information on the problem.

Attachments
Purchase this Solution

Solution Summary

The attached program includes a structure with a tag name info.
It contains the following data as members:
a character array to store person's name, defined as: name[30]
a character array to store person's street address, defined as: address[30]
a character array to store person's city, defined as: city[20]
a character array to store person's state, defined as: state[3]
a long integer variable to store person's zip code, defined as: zip
an integer variable to store person's age, defined as: age
a character variable to store person's gender, defined as: gender

An array of type struct info has been declared called people[10].

An example dialog with the user is as follows:

Whatever Title you want Here
Enter name: Minnie Mouse
Enter street address: 100 Disney Drive
Enter city: Orlando
Enter state: FL
Enter zip code: 99990
Enter age: 25
Enter gender (M or F): F

Enter name: Big Bird
Enter street address: 10 Sesame Street
Enter city: Funtown
Enter state: MA
Enter zip code: 01222
Enter age: 20
Enter gender (M or F): M

The information you entered is:
Minnie Mouse
100 Disney Drive
Orlando, FL 99990
She is 25 years old.
Big Bird
10 Sesame Street
Funtown, MA 01222
He is 20 years old.

? Uses gets to read in more than one word at a time. (Needed for "name" , "address" and "city", in this program.)

? Uses fflush(stdin); This removes any extraneous characters (like carriage returns) from the input buffer.

? It tests for both uppercase, and lowercase values of M and F. For example, the user may enter "m" or "M" as the gender, in either case, the program interprets correctly that it is a male. (If neither M, m, F, or f is entered for gender, then the program does not display any age information.)

? Error checking is performed on the age input (allows between 1 and 120)

Solution Preview

The attached program includes a structure with a tag name info.
It contains the following data as members:
a character array to store person's name, defined as: name[30]
a character array to store person's street address, defined as: address[30]
a character array to store person's city, defined as: city[20]
a character array to store person's state, defined as: state[3]
a long integer variable to store person's zip ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Javscript Basics

Quiz on basics of javascript programming language.