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

f.edu Week 11 223C-18Summer C0O1> Assignments> Week 11 Week 11 Submt Assignment

ID: 3919079 • Letter: F

Question

f.edu Week 11 223C-18Summer C0O1> Assignments> Week 11 Week 11 Submt Assignment ents Due Sunday by 11:59pm Points 100 Submitting a file upload Available Jul 16 at 12am-Jul 29 at 11:59pm 14 days data structures Create a Code Blocks project named Linked Lists. This program will use a set of into which the user will enter contact information. Globally declare a Contactinfo struct. Create a function that asks for contact information and places the information into a struct Contactinfo "getContactinfol void) Call getContactinfo ten times from a for loop, and each time add the new data structure to the end of the list (use a function named addContactinfoToListt Contactinfo "info ) to add the new data structure to the list).. ns Write a function that displays all of the data in the list Submit your source code to the webcourse. ide

Explanation / Answer

here is the complete Program as per the requirement..

=========================================================

Program:

=========================================================

//header files

#include<iostream>

#include<cstdlib>

//namespace

using namespace std;

//global structure

struct ContactInfo

{

string name;

string ph;

ContactInfo *next;

};

//memory allocation for head pointer

ContactInfo *head = NULL;

//get user info

ContactInfo *getContactInfo()

{

ContactInfo *new_info = new ContactInfo;

cout<<"Enter Name: ";

cin>>new_info->name;

cout<<"Enter phone number: ";

cin>>new_info->ph;

return new_info;

}

//add information to node

void addContactInfoToList(ContactInfo *info)

{

info->next = head;

head = info;

}
//display information

void displayInfo()

{

cout<<"*******Contact Info*******"<<endl;

cout<<"---------------------------"<<endl;

if(!head)

{

cout<<"Sorry there is no data."<<endl;

return;

}

while(head != NULL)

{

cout<<"Name: "<<head->name<<endl;

cout<<"Phone number: "<<head->ph<<endl;

cout<<endl;

head = head->next;

}

}

//start of main function

int main()

{

//creating an info NULL node

ContactInfo *info = NULL;

//loop for 10 times

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

{

//call function and store the info

info = getContactInfo();

//call to addContactInfoToList function

addContactInfoToList(info);

}

//call to display function

displayInfo();

return 0;

}
//end of main function

==========================================================

Sample Output:

Enter Name: A
Enter phone number: 1111111111
Enter Name: B
Enter phone number: 2222222222
Enter Name: C
Enter phone number: 3333333333
Enter Name: D
Enter phone number: 4444444444
Enter Name: E
Enter phone number: 5555555555
Enter Name: F
Enter phone number: 6666666666
Enter Name: G
Enter phone number: 7777777777
Enter Name: H
Enter phone number: 8888888888
Enter Name: I
Enter phone number: 9999999999
Enter Name: J
Enter phone number: 1234567891
*******Contact Info*******
---------------------------
Name: J
Phone number: 1234567891

Name: I
Phone number: 9999999999

Name: H
Phone number: 8888888888

Name: G
Phone number: 7777777777

Name: F
Phone number: 6666666666

Name: E
Phone number: 5555555555

Name: D
Phone number: 4444444444

Name: C
Phone number: 3333333333

Name: B
Phone number: 2222222222

Name: A
Phone number: 1111111111


===================================================================