Question

Please create a program answering the following question. In C PROGRAMMING!

Contactlnformation Create a program with the following requirements 1. You must have a data structure for personal contact information 2. Declare one of your contact information data structures locally in main 3. Create a function that allows users to enter in all of the information that populates the data structure that was passed in 4. Create a function that displays the information that was entered into the data structure lease enter your contact information irst Name: sam ast Name:hill ity:hereville tate:nc ip:12345 hone: 9998887654 ere is the information you entered irst Name: sam ast Name:hill ity:hereville tate:nc ip:12345 hone: 9998887654 rocess returned e (exe execution time17.933 s ress any key to continue.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

#include<stdlib.h>

#include<iostream>

using namespace std;

struct information //structure declaration

{

char fname[20];

char lname[20];

char city[20];

char state[15];

int zip;

int phone;

};

int main()

{

struct information *ptr; //declaration of pointer ptr pointing to the structure information

int i, entry;

printf("Enter number of records for the contact information: ");

scanf("%d", &entry); //getting the no of entries

ptr = (struct information*) malloc (entry * sizeof(struct information)); // Allocates the memory for each entry structures with pointer ptr pointing to the base address.

for(i = 0; i < entry; ++i) //loop for getting each time the informations for respective number of entries

{

printf("\nFor %d information : ", i+1);

printf("\nFirst Name: ");

scanf("%s",&(ptr+i)->fname); //pointing to the base address where the firstname memory has been allocated.

printf("\nLast Name : ");

scanf("%s",&(ptr+i)->lname); //pointing to the base address where the lastname memory has been allocated.

printf("\nCity : ");

scanf("%s",&(ptr+i)->city);

printf("\nState : ");

scanf("%s",&(ptr+i)->state);

printf("\nZip : ");

scanf("%d",&(ptr+i)->zip);

printf("\nPhone No : ");

scanf("%d",&(ptr+i)->phone);

printf("\n\n");

}

printf("Here is the Information you entered:\n");

for(i = 0; i < entry ; ++i) // loop to display all the information

{

printf("\n%d information : ", i+1);

printf("\nFirst Name : %s", (ptr+i)->fname);

printf("\nLast Name : %s", (ptr+i)->lname);

printf("\nCity : %s", (ptr+i)->city);

printf("\nState : %s", (ptr+i)->state);

printf("\nZip : %d", (ptr+i)->zip);

printf("\nPhone No : %d", (ptr+i)->phone);

printf("\n\n");

}

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Please create a program answering the following question. In C PROGRAMMING! Contactlnformation Create a program with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please create a program answering the following question in C PROGRAMMING. CorrectFormation Create a program and...

    Please create a program answering the following question in C PROGRAMMING. CorrectFormation Create a program and locally declare in main fname and Iname and completeName. Ask the user for their first and last name. Put the values into fname and Iname. You will create a function that is called as followed oinNames( fname, Iname, completeName ); You will pass the first name array, the last name array, and the array that will contain the complete name. The function named joinNames...

  • I need help programming this question using C language. This program uses input data entered in...

    I need help programming this question using C language. This program uses input data entered in command line at the same time when the command or .exe file is entered. They are called command-line arguments. Because everything entered in command line is taken as a string, these arguments including the command itself or the .exe file name are stored in an array of char pointers, each pointer points to the first character of a string (i.e., argument). The inputs can...

  • *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create...

    *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create an array of doubles named “hummus” with 2 rows and 300 columns. Initialize all array elements to zero. Write a loop that will repeatedly ask the user to enter a value and store it in the first row of the array (do not overwrite previously entered values) until the whole first row is populated with the user input. (hint the loop should have the...

  • Please write this program in C++, thanks Task 9.3 Write a complete C++ program to create a music player Your program sh...

    Please write this program in C++, thanks Task 9.3 Write a complete C++ program to create a music player Your program should read in several album names, each album has up to 5 tracks as well as a genre. First declare genre for the album as an enumeration with at least three entries. Then declare an album structure that has five elements to hold the album name, genre, number of tracks, name of those tracks and track location. You can...

  • Write this in a C program please. Structures on Disk The Problem Your task is to...

    Write this in a C program please. Structures on Disk The Problem Your task is to write a program that stores and retrieves structures in a file on disk. The file of structures must remain on the disk once your program ends. You should be able to store structures to the file and retrieve from the file after restarting the program. The record that you will be writing to file has the following structure: struct contact {unsigned long phone_number; long...

  • DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to...

    DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...

  • c++ Instructions Overview In this programming challenge you will create a program to handle student test...

    c++ Instructions Overview In this programming challenge you will create a program to handle student test scores.  You will have three tasks to complete in this challenge. Instructions Task 1 Write a program that allocates an array large enough to hold 5 student test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the...

  • this program is in C. Write a program that computes the number of elements in an...

    this program is in C. Write a program that computes the number of elements in an array divisible by a user specified number. Declare an integer array of size 7 and read the array elements from the user. Then, read a number k from the user and compute the number of elements in the array divisible by k. Consider the following example. 3 elements in this array are divisible by 2 ({2,2,4}). Sample execution of the program for this array...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • In C++ write a program; Your goal is to create a structure to store information about...

    In C++ write a program; Your goal is to create a structure to store information about a movie. Your program should have the following: -The name of the program should be Assignment8. -3 comment lines (description of the program, author, and date) -Write a program that uses a structure named MovieData to store the following information about a movie: (3 points) Title, Director, Year released, Running time (in minutes) The program should create 2 MovieData variables, store values in their...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT