Answer to Question #153678 in C++ for Alex

Question #153678

Write a program that implements the following using C++ structure. The program should finally displays the values stored in a phone directory (for 10 people)

1)Name

2)phone number

3)city and country



1
Expert's answer
2021-01-04T03:37:12-0500

#include <iostream>


// The program will prompt the user to enter nameS of 10 users

//The vales shall be stored in a structure

//The for loop shall be used to read and display the info.



using namespace std;


struct phone // structure name is phone

{

   char name[10]; //memmbers

  char phonenumber[10];

  char country[10];

  char city[10];


};



int main(){

   int n=2;


phone dir[10];

for(int i=0;i<n;++i){


cout<<"Enter name for person "<<i+1<<endl;

cin>>dir[i].name;


cout<<"Enter phone number for person "<<i+1<<endl;

cin>>dir[i].phonenumber;


cout<<"Enter country for person "<<i+1<<endl;

cin>>dir[i].country;


cout<<"Enter city for person "<<i+1<<endl;

cin>>dir[i].city;


}

cout<<"************************************"<<endl;

for( i=0;i<n;++i){

cout<<"************************************"<<endl;

cout<<"Details for person"<<i+1<<endl;

cout<<"______________________________________"<<endl;

cout<<"Name "<<dir[i].name<<endl;

cout<<"______________________________________"<<endl;


cout<<"Phone number "<<dir[i].phonenumber<<endl;


cout<<"______________________________________"<<endl;

cout<<"Country "<<dir[i].country<<endl;

cout<<"______________________________________"<<endl;


cout<<"City "<<dir[i].city<<endl;


}


cout<<"************************************"<<endl;

   return 0;

}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog