Friday 11 July 2014

The program illustrates the use of array of objects to store and display the name and telephone number of 50 subscribers.

 
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class subscriber
          {        char name [20] ;
                   long int phone;
          public :
          void read_data ()
                   {
                   cout<<"Enter name phone number of 50 students:";
                   gets (name);
                   cin>>phone;
                   }
          void print_data ()
                   {
                   cout<<name<<"\t"<<phone<<"\n";
                   }
};

void main ( )
{
subscriber ob [50] ;
for (int i=0;i<50;i++)
          ob [i]. read_data ( ) ;
for (i=0;i<50;i++)
          ob [i]. print_data ( ) ;
getch();
}

No comments:

Post a Comment