Telephone Book C++ Program
/* Problem Statement : Write a program that defines a structure containing 3 elements that describe an entry in your telephone book: one is the name of your friend not exceeding 20 characters, his/her telephone number and date of birth (which is a structure variable containing 3 integers for day, month and year). Use the same for storing and displaying entries for a friend. */
#include<iostream>
using namespace std;
struct Dob
{
int day;
int month ;
int year;
};
struct telephone
{
char name[20];
int number;
struct Dob d;
};
int main()
{
int count;
struct telephone t[10];
cout<<"\nEnter the no. of details to input : ";
cin>>count;
cout<<"\nEnter the Details:\n";
for(int i=0; i<count; i++)
{
cout<<"\nEnter Name : ";
cin>>t[i].name;
cout<<"\nEnter number : ";
cin>>t[i].number;
cout<<"\nEnter Date of birth : ";
cout<<"\nEnter day : ";
cin>>t[i].d.day;
cout<<"\nEnter month : ";
cin>>t[i].d.month;
cout<<"\nEnter year : ";
cin>>t[i].d.year;
cout<<"\n\n";
}
cout<<"The phone book entry is as follow .\n\n";
cout<<"\tNAME";
cout<<"\t\tNUMBER";
cout<<"\t\tDATE OF BIRTH\n";
for(int i=0; i<count; i++)
{
cout<<"\t"<<t[i].name;
cout<<"\t\t"<<t[i].number;
cout<<"\t\t"<<t[i].d.day;
cout<<"."<<t[i].d.month;
cout<<"."<<t[i].d.year;
cout<<"\n\n";
}
return 0;
}
Problem Statement : Write a program that defines a structure containing 3 elements that describe an entry in your telephone book: one is the name of your friend not exceeding 20 characters, his/her telephone number and date of birth (which is a structure variable containing 3 integers for day, month and year). Use the same for storing and displaying entries for a friend.
#COFPROG
Sign up here with your email
ConversionConversion EmoticonEmoticon