Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Please Write In C-Free Software Or Write It Out!

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 sample run below.

Your program should include a structure with a tag name of: info. It should contain 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

You need to define an array of type: struct info. You can call this array: people[10].

The dialog with the user must be 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.

Note: The coral text represents the "output" from your program and is shown for clarity only here. It is not required that your output be in this color. (Do not even attempt to try!). Also note that what the user types in is indicated by the blue area above. Again, for clarity only.

Hints/other requirements:
• Use gets (or safer_gets() ) instead of scanf to read in more than one word at a time. (Needed for "name" , "address" and "city", in this program.)

• Call fflush(stdin); after any scanf (or getchar) for gender. This will remove any extraneous characters (like carriage returns) from the input buffer.

• Structure member state is a 3 element array, not 2. In this field you will be storing a 2 character abbreviation of a state. We need to define the extra (3rd) element to hold the null terminator character.

• If you use %li (instead of %ld) as the format specifier for the "zip code" and if you enter your zip code starting with the number 0 (zero), C will interpret that number as "octal" and which will cause erroneous results. The %i format specifier says to interpret any number starting with a zero as octal. For this reason, I recommend that you use %ld in the scanf statement when prompting the user for the zip code.

• The above hint handles the zip code as it is being input using a scanf statement. You have a different problem when you want to output the zip code using a printf statement. C does not store leading zeros. So, if the user in fact enters a zip code starting with a zero, you need to do some extra formatting when you output the zip code to display leading zeros if any. You have 2 choices: Either: %.5ld or %05ld. Both of those format specifiers indicate that you want C to reserve 5 spaces for the output, and if the integer value is less than 5 digits, to pad the integer with leading zeros.

• You do not need to use functions in this program (however, feel free to if you'd like).

• You do not need to use pointers in this program.

• Gender should be entered as either M for male, or F for female. Your program should test for "M"ale or "F"emale gender to determine whether to output the age as: He is... or She is... (refer to sample output below for more info.) Remember to test 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, your program should interpret it as male. (If neither M, m, F, or f is entered for gender, your program should not display any age information.)

• You need to perform error checking on only the age user input (between 1 and 120, hey who knows?).

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91621453
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Programming Language

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As