Quiz Test.

#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<fstream.h>
class contest
{
private:
    int roll;
    float x;
    char name[20];
    char s[100],ans;

public:
    contest()
    { x=0; }
    void init();
    void define();
    void display();
};
void  contest :: define()
{
   ifstream in;
   char a;
      int i=0;
   in.open("ques.txt");
    while(in.eof()==0)
    {
    in.getline(s,100);
    cout<<endl<<s;
   if(i==5)
   {
   in.get(a);
   cout<<"\nans:";
    cin>>ans;
   i=-1;
    if(ans==a)
       {
       x=x+5;
       cout<<" *Your ans  correct.\n";
       }
    else
       {
       if(x>0)
        x=x-2.5;
       cout<<" # Wrong ans.\n";
       }
    }
    i++;
    }
   in.close();
}
     void contest :: init()
       {
     cout<<"\t\t\t   Examinee Name:";
     cin>>name;
     cout<<"\t\t\t   Examinee roll:";
     cin>>roll;
       }
     void contest :: display()
       {
     cout<<"\n **Result:\n";
     cout<<"\t"<<name<<" you got total "<<x<<" marks,out of 50.\n";
       }

void main()
{
    clrscr();
    contest r;
    cout<<"      \t\t\t~~~*** QUIZ CONTEST ***~~~\t      Total Marks:50\n\n";
    r.init();
    cout<<"\t*5 marks per Ques(half negative marking for wrong ans)";
       L:
    cout<<"\n\n\tselect your choice:\n"
        <<"\n\t1 for start exam"
        <<"\n\t0 for quit the exam :";
       int c;
       cin>>c;
       switch(c)
       {
       case 1:
        r.define();
        r.display();
        break;
       case 0:
        exit(1);
       default:
        cout<<"invalid choice!";
        goto L;
       }
       getch();
}

A file(QUES.TXT) must be made or copied to the directory (drive_name:\tc\bin\ ). with the cpp file. Some include this file like as,


QUES.TXT Data :

1.WHEN COMPUTER WAS FIRST INVENTIONED?
a.1822
b.1823
c.1834
d.1922
a
2.WHO kILLED PRESEDENT BENOGIR VUTTO?
a.nawaz shrif
b.pervase
c.non of them
d.political leder
c
3.WHO IS THE CAPTAIN OF BANGLADESH CRICKET TREAM?
a.asharaful
b.murtaja
c.rafiq
d.aftab
a
4.WHAT IS OUR NATIONAL GAME?
a.cicket
b.football
c.hadodo
d.badminton
c
5.WHO IS NOW CHIEFJUSTICS IN BANGLADESH?
a.yeaz uddin
b.moin
c.jalil
d.fakhar uddin
d
6.WHO IS THE PRIME MINISTER OF INDIA?
a.sonia gundi
b.rajib gundi
c.autol biharipal
d.pervase
c
7.WHAT IS THE DATE OF SIDDR ORCUS?
a.16th nov
b.17th nov
c.18th nov
d.20th n0v
a
8.WHEN WILL BE THE NEXT WORLD CUP CRICKET?
a.2011
b.2012
c.2009
d.2008
a
9.WHERE WILL BE THE NEXT WORLD CUP CRICKET?
a.india
b.pakistan
c.africa
d.bangladesh
d
10.WHICH COUNTRY WIN THE 2007 CRICKET WORLD CUP?
a.australia
b.bangladesh
c.srilanka
d.india

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........

Department of Computer Science and Engineering Database.

#include <iostream.h>
#include <conio.h>
#include <fstream.h>
#include <process.h>
#include <string.h>


class office
{
 private:
     int salary,house_rent,medical,recreation;
     int elec_bill,tel_bill;
     long int tel_no;
     char *name,name1[15],name2[15],e_mail[30];
 public:
    void getdata(void);
    void nameconcate(void);
    void calculation(void);
    void display(void);
  };

 void office :: getdata (void)
 {
  cout<<"Enter your first name please :";
  cin>>name1;
  cout<<endl;
  cout<<"Enter your last name please  :";
  cin>>name2;
  cout<<endl;
  cout<<"Now enter basic salary please:";
  cin>>salary;
  cout<<endl;
  cout<<"Enter your mobile no.        :";
  cin>>tel_no;
  cout<<endl;
  cout<<"Enter your e-mail address    :";
  cin>>e_mail;
  cout<<endl;
  }

  void office :: nameconcate (void)
  {
    int length1 = strlen(name1);
    int length2 = strlen(name2);
    name = new char[length1+length2+3];
    strcpy(name,name1);
    strcat(name,name2);
   }

 void office :: calculation (void)
 {
  char ans;

  house_rent=5000;
  elec_bill=400;
  tel_bill=800;
  medical=1000;
  recreation=2000;

  salary=salary+medical;
  salary=salary+recreation;
  salary=salary+house_rent;
  salary=salary+elec_bill;
  salary=salary+tel_bill;

  cout<<"Do you want to use quater facilities provided by university or"<<endl;
  cout<<"want to maintain it on your own?"<<endl;
  cout<<"Press y or n as your answer  :";
  cin>>ans;
  cout<<endl;

  if(ans=='y')
  salary=salary-house_rent;
  salary=salary-elec_bill;
  salary-salary-tel_bill;

  }

  void office :: display (void)
  {
   cout<<"Name          : "<<name<<endl;
   cout<<"Salary        : "<<salary<<endl;
   cout<<"Mobile        : "<<tel_no<<endl;
   cout<<"E-mail        : "<<e_mail<<endl;
   cout<<endl<<endl;

   }

  int main()
  {
   office prof[3],assist_prof[7],lecturer[15],staff[5];

   fstream file;

   char key;
   int choice,serial,loc;
   int static i,j,k,l;

   clrscr();

   file.open("database",ios::in|ios::out|ios::ate);

   do
   {
   cout<<"Welcome to Department of Computer Science and ";
   cout<<"Engineering Database."<<endl<<endl;
   cout<<"E-mail : head@cse.kuet.ac.bd"<<endl<<endl;
   cout<<'\t'<<" -----------------------------------------------";
   cout<<"-------------------"<<endl<<'\t'<<"|";
   cout<<'\t'<<"CHOICE"<<'\t'<<'\t'<<'\t'<<"TASK                   ";
   cout<<"            |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"------"<<'\t'<<'\t'<<'\t'<<"----        ";
   cout<<"                       |"<<endl;
   cout<<'\t'<<"|"<<"                                         ";
   cout<<"                         |" <<endl;
   cout<<'\t'<<"|"<<'\t'<<"1"<<'\t'<<'\t'<<'\t'<<"Add a Professor    ";
   cout<<"                |"<<endl;
   cout<<'\t'<<"|                                              ";
   cout<<"                    |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"2"<<'\t'<<'\t'<<'\t'<<"Add an Assistant Professor";
   cout<<"         |";
   cout<<endl<<'\t'<<"|                                            ";
   cout<<"                      |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"3"<<'\t'<<'\t'<<'\t'<<"Add a Lecturer";
   cout<<"                     |"<<endl;
   cout<<'\t'<<"|                                                   ";
   cout<<"               |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"4"<<'\t'<<'\t'<<'\t'<<"Add a Staff     ";
   cout<<"                   |"<<endl;
   cout<<'\t'<<"|                                                  ";
   cout<<"                |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"5"<<'\t'<<'\t'<<'\t'<<"View all Database";
   cout<<"                  |"<<endl;
   cout<<'\t'<<"|                                                   ";
   cout<<"               |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"6"<<'\t'<<'\t'<<'\t'<<"Modify Database";
   cout<<"                    |"<<endl;
   cout<<'\t'<<"|                                                   ";
   cout<<"               |"<<endl;
   cout<<'\t'<<"|"<<'\t'<<"7"<<'\t'<<'\t'<<'\t'<<"Exit from Database";
   cout<<"                 |"<<endl;
   cout<<'\t'<<" -------------------------------------------";
   cout<<"----------------------"<<endl;
   cout<<endl<<endl;
   cout<<"Your Choice   : ";
   cin>>choice;
   cout<<endl;

   switch(choice)
   {
    case 1:


    if(i>2)
    {
    cout<<"No additional recruiting is possible in this section."<<endl<<endl;
    }
    else
    {
    cout<<"Data for Professor "<<i+1<<" : "<<endl<<endl;
    prof[i].getdata();
    prof[i].nameconcate();
    prof[i].calculation();
    file.write( (char*)&prof[i],sizeof(prof[i]) );
    file.clear();
    i++;
     }
    break;

    case 2:

    if(j>6)
    {
    cout<<"No additional recruiting is possible in this section."<<endl<<endl;
    }
    else
    {
    cout<<"Data for Assistant Professor "<<j+1<<" : "<<endl<<endl;
    assist_prof[j].getdata();
    assist_prof[j].nameconcate();
    assist_prof[j].calculation();
    file.write( (char*)&assist_prof[j],sizeof(assist_prof[j]) );
    file.clear();
    j++;
    }
    break;

    case 3:

    if(k>14)
    {
    cout<<"No additional recruiting is possible in this section."<<endl<<endl;
    }
    else
    {
    cout<<"Data for Lecturer "<<k+1<<" : "<<endl<<endl;
    lecturer[k].getdata();
    lecturer[k].nameconcate();
    lecturer[k].calculation();
    file.write( (char*)&lecturer[k],sizeof(lecturer[k]) );
    file.clear();
    k++;
    }
    break;

    case 4:

    if(l>4)
    {
    cout<<"No additional recruiting is possible in this section."<<endl<<endl;
    }
    else
    {
    cout<<"Data for Staff "<<l+1<<" : "<<endl<<endl;
    staff[l].getdata();
    staff[l].nameconcate();
    staff[l].calculation();
    file.write( (char*)&staff[l],sizeof(staff[l]) );
    file.clear();
    l++;
    }
    break;

    case 5:

    if(i>0)
    {
    cout<<"Professor Section           :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int m=0;m<i;m++)
      file.read( (char*)&prof[m],sizeof(prof[m]) );
      prof[m].display();
      file.clear();
    }
     }

    if(j>0)
    {
    cout<<"Assistant Professor Section :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int n=0;n<j;n++)
      file.read( (char*)&assist_prof[n],sizeof(assist_prof[n]) );
      assist_prof[n].display();
      file.clear();
    }
     }

    if(k>0)
    {
    cout<<"Lecturer Section            :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int p=0;p<k;p++)
      file.read( (char*)&lecturer[p],sizeof(lecturer[p]) );
      lecturer[p].display();
      file.clear();
    }
     }

    if(l>0)
    {
    cout<<"Staff Section               :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int q=0;q<l;q++)
      file.read( (char*)&staff[q],sizeof(staff[q]) );
      staff[q].display();
      file.clear();
    }
     }

    break;

    case 6:

    cout<<"Modify a professor/assistant professor/lecturer/staff?"<<endl;
    cout<<endl<<"Please use 'p'/'a'/'l'/'s' as  the keyword..."<<endl<<endl;
    cout<<"Keyword :-";
    cin>>key;

    if(key=='p')
    {
    cout<<"Professor Section           :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int m=0;m<i;m++)
      file.read( (char*)&prof[m],sizeof(prof[m]) );
      cout<<m+1<<"."<<endl;
      prof[m].display();
      file.clear();
    }
    cout<<endl<<endl<<"Now enter the serial no. of the professor you want";
    cout<<"to modify..."<<endl<<endl;
    cin>>serial;

    loc=( (serial-1)*sizeof(prof[0]) );

       prof[serial].getdata();
       prof[serial].nameconcate();
       prof[serial].calculation();
       file.seekp(loc);
       file.write( (char *)&prof[serial],sizeof(prof[serial]) );
     }

    else if(key=='a')
    {
    cout<<"Assistant Professor Section :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int n=0;n<j;n++)
      file.read( (char*)&assist_prof[n],sizeof(assist_prof[n]) );
      cout<<n+1<<"."<<endl;
      assist_prof[n].display();
      file.clear();
    }
    cout<<endl<<endl<<"Now enter the serial no. of the assistant professor";
    cout<<"you want to modify..."<<endl<<endl;
    cin>>serial;

    loc=( (serial-1)*sizeof(assist_prof[0]) );

       assist_prof[serial].getdata();
       assist_prof[serial].nameconcate();
       assist_prof[serial].calculation();
       file.seekp(loc);
       file.write( (char *)&assist_prof[serial],sizeof(assist_prof[serial]) );
    }
    else if(key=='l')
    {
    cout<<"Lecturer Section            :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int p=0;p<k;p++)
      file.read( (char*)&lecturer[p],sizeof(lecturer[p]) );
      cout<<p+1<<"."<<endl;
      lecturer[p].display();
      file.clear();
    }
    cout<<endl<<endl<<"Now enter the serial no. of the lecturer";
    cout<<"you want to modify..."<<endl<<endl;
    cin>>serial;

    loc=( (serial-1)*sizeof(lecturer[0]) );

       lecturer[serial].getdata();
       lecturer[serial].nameconcate();
       lecturer[serial].calculation();
       file.seekp(loc);
       file.write( (char *)&lecturer[serial],sizeof(lecturer[serial]) );
    }
    else if(key=='s')
    {
    cout<<"Staff Section               :- ";
    cout<<endl<<endl;
    file.seekg(0);
    { for(int q=0;q<l;q++)
      file.read( (char*)&staff[q],sizeof(staff[q]) );
      cout<<q+1<<"."<<endl;
      staff[q].display();
      file.clear();
    }
    cout<<endl<<endl<<"Now enter the serial no. of the staff";
    cout<<"you want to modify..."<<endl<<endl;
    cin>>serial;

    loc=( (serial-1)*sizeof(staff[0]) );

       staff[serial].getdata();
       staff[serial].nameconcate();
       staff[serial].calculation();
       file.seekp(loc);
       file.write( (char *)&staff[serial],sizeof(staff[serial]) );
    }

    break;

    case 7:
    exit(1);
    }

      }
    while(choice==1||2||3||4||5||6);

    getch();

    file.close();

    return 0;

    }

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........

Learning Object Oriented Programming Using C++.

 #include<iostream.h>
 #include<conio.h>
 #include<string.h>
 #include<stdlib.h>


 class assignment
 {
  public:
   void f_page();
   void class_object();
   void features();
   void members();
   void function_overloading();
   void default_parameter();
  };

  void assignment::f_page()
  {
   cout<<"\n\n\t\t\t :OOP TUTORIAL:";
   cout<<"\n\t\t\t================";
   cout<<"\n\n\t :LEARNING OBJECT ORIENTED PROGRAMMING USING C++:";
   cout<<"\n\t--------------------------------------------------";
   cout<<"\n\n\t1. Concept Of Class And Object.\n\n\t2. Features Of OOP.\n\n\
\t3. Private,Public And Protected Members.\n\n\t4. Function Overloading.\n\
\n\t5. Default Parameter.\n\n\t** Enter 0 For Exit.** Enter Your Choice: ";
  int i;   cin>>i;
  switch(i)
  {
  case 0:exit(0);                   break;
  case 1:class_object();            break;
  case 2:features();                break;
  case 3:members();                 break;
  case 4:function_overloading();    break;
  case 5:default_parameter();       break;

  }
 }

 //===================Concept Of Class And Object=======================\\
 //----------------------------------------------------------------------\\

 void assignment::class_object()
 {
  clrscr();
  cout<<"\n\n\t\t :CONCEPT OF CLASS AND OBJECT:";
  cout<<"\n\t\t===============================";
  cout<<"\n\n\t\t\t :CLASS AND OBJECT:";
  cout<<"\n\t\t\t====================";
  cout<<"\n\n\t1. What is class ?\n\n\t2. Uses of class ?\n\n\t3. General\
Format.\n\n\t4. What is object ?\n\n\t5. Uses of object ?\n\n\t6. General\
Format.\n\n\t7. Press 7 to return front page.\n\n\n\t ** Enter Your Choice:";
  int a;
  cin>>a;
  switch(a)
  {
   case 1: clrscr();
       cout<<"\n\n\tCLASS: Class is a user defined data type.It is declr\
ared using class\n\nkeyword.The syntax of a class decleration is similar to\
that of astructure.\n\n\n * Press Any Key To Go Back Page *"; getch();
       class_object();            break;
   case 2: clrscr();
       cout<<"\n\n\tUSES: It is a important features of Object Oriented\
Programming.To\n\ndescribe a object we use class.Class is also used to handle\
many operations.\n\n\t * Press Any Key To Go Back Page *"; getch();
      class_object();            break;
   case 3:clrscr();
      cout<<"\n\n\tGeneral Format:\n\n\t class class_name{\n\n\t //\
private finction and variable.\n\n\tprivate:\n\n\t //public function and\
variable.\n\n\t}object list;\n\n\t * Press Any Key To Go Back Page *"; getch();
      class_object();             break;
   case 4:clrscr();
      cout<<"\n\n\tOBJECT: Object is a class type variable.It is a \
basic run time entities\n\nin an object-oriented system.\n\n\t * Press Any \
Key To Go Back Page *";  getch();

      class_object();             break;
   case 5:clrscr();
      cout<<"\n\n\tUSES: Object is mainly used in a class.It is a run \
time NTT of OOP.Each\n\nobject of a class has its own copy of every variable \
declared within the class.\n\n\t * Press Any Key To Go Back Page *";getch();
      class_object();              break;
   case 6:clrscr();
      cout<<"\n\n\tGeneral Format:\n\n\t\tclass class_name{\n\n\t\t //\
private functions and variables.\n\n\t\tpublic:\n\n\t\t //public functions \
and variables.\n\n\t\t}object list;\n\n\t * Press Any Key To Go Back Page *";
      getch();
      class_object();             break;
   case 7:clrscr();
      f_page();                   break;
  }
  getch();
  }

  //=====================Features Of OOP=============================\\
 //------------------------------------------------------------------\\

 void assignment::features()
 {
  clrscr();
  cout<<"\n\n\t\t:FEATURES OF OOP:";
  cout<<"\n\n\t\t==================";
  cout<<"\n\n\t\t1. Abstruction.\n\n\t\t2. Encaptulation.\n\n\t\t3. Dynamic\
 Binding.\n\n\t\t4. Press 4 To Return Front Page.\n\n\t\t ** Enter Your Choic\
 e: ";
  int a;
  cin>>a;
  switch(a)
  {
   case 1:clrscr();
      cout<<"\n\n\t\t\t :ABSTRUCTION:\n\n\t\t\t================\n\n\t\t\
Abstruction refers to the act of representing essential features\nwithout \
including the background details or explanations.Classes use the concept\n\
of abstruction and are defined as a list of abstruct attributes as size,\
\n\nweight and cost, and functions to operate on these attributes.\n\n\t\t \
 * Press Any Key To Go To BAck Page *";getch();
      features();              break;
   case 2:clrscr();
      cout<<"\n\n\t\t\t :ENCAPTULATION:\n\t\t\t=================\n\n\t\
\tEncaptulation is the mechanism that binds together code and the\n\ndata it\
manipulates, and keeps both safe from outside interference and misuse. In\n\
any object the private data and its related function are binded together\
,so\n\nthat nothing from outside can directly access these private members\
.Even if one\n\nobject cannot access or change the intrnal state of another\
object of same class.\nOnly the own methods involving with that object c\
an allowed to access or change\n\nits inernal state.\n\n\t\t * Press Any Key \
TO Go To Back Page * ";getch();
       features();               break;
    case 3:clrscr();
       cout<<"\n\n\t\t\t :DYNAMIC BINDING:\n\t\t\t===================\n\
\n\t\tIn object oriented programming it is possible to impliment\n\ndifferent\
 version of a particular function.But it is not known which version of\n\nthat\
 function will call untill runtime.This system is calles dynamic binding.\n\n\
There nare two types of binding one is early binding that is not known\n\n\
untill compile time and another is late binding that is not known untill \
runtime.\n\n\n * Press Any Key To Go To BAck Page *";getch();
       features();               break;
    case 4:clrscr();
       f_page();                break;
  }
  getch();
  }

 //==============Privatre, Public And Protected Members==================\\
 //-----------------------------------------------------------------------\\

 void assignment::members()
 {
  clrscr();
  cout<<"\n\n\t\t\t :PRIVATE, PUBLIC AND PROTECTED MEMBERS:";
  cout<<"\n\n\t\t\t=========================================";
  cout<<"\n\n\t\t1. Variables.\n\n\t\t2. Functions.\n\n\t\t3. press 3 To\
 Return Front Page.\n\n\n\t\tEnter Your Choice:";
  int a;
  cin>>a;
  switch(a)
  {
   case 1:clrscr();
      cout<<"\n\n\t\t PRIVATE, PUBLIC AND PROTECTED VARIABLES:\n\n\t\t\
------------------------------------------\n\n\t\tPrivate variable can be\
declared defaultly withing using private\n\naccess specier.We can not use a p\
rivate variable directly anywhere in the\n\nprogram.Public member variable is\
 declared with public access specier.We can use\npublic variable directly any\
where in the program.Protected member variable\n\nis declared with protected\
access specier.It like as private member variable. But\nwe can inherite it\
directly.\n\n\n\t\tGeneral Format:\n\n\t\t class class_name{\n\n\t\t  \
//private variables.\n\n\t\t public:\n\n\t\t  //public variables.\n\n\t\t \
protected:\n\n\t\t  //protected variables.\n\n\t\t};\n\n\n\t\t * Press Any \
Key To Go To Back Page *";  getch();
      members();              break;
   case 2:clrscr();
      cout<<"\n\n\t\t PRIVATE, PUBLIC AND PROTECTED FUNCTIONS:\n\n\t\t\
------------------------------------------\n\n\t\tPrivate functions can be\
declared defaultly withing using private\n\naccess specier.We can not use a p\
rivate functions directly anywhere in the\n\nprogram.Public member function is\
 declared with public access specier.We can use\npublic function directly any\
where in the program.Protected member function\n\nis declared with protected\
access specier.It like as private member function. But\nwe can inherite it\
directly.\n\n\n\t\tGeneral Format:\n\n\t\t class class_name{\n\n\t\t  \
//private functions.\n\n\t\t public:\n\n\t\t  //public functions.\n\n\t\t \
protected:\n\n\t\t  //protected functions.\n\n\t\t};\n\n\n\t\t * Press Any \
 Key To Go To Back Page *";  getch();
        members();              break;
     case 3:clrscr();
        f_page();             break;
  }
  getch();
  }

 //=======================Function Overloading==========================\\
 //---------------------------------------------------------------------\\

 int add(int a,int b)
 {
   return a+b;
 }
int add(int x,int y,int z)
 {
  return x+y+z;
 }
 void assignment::function_overloading()
 {
  clrscr();
  cout<<"\n\n\t\t\t :FUNCTION OVERLOADING:\n\t\t\t========================";
  cout<<"\n\n\t\t1. What is function overloading ?\n\n\t\t2. Why function \
overloading is used ?\n\n\t\t3. General format.\n\n\t\t4. Example.\n\n\t\t5.\
 Press 5 To Return Front Page.\n\n\n\t\t  **Enter Your Choice:";
  int a;
  cin>>a;
  switch(a)
  {
   case 1:clrscr();
      cout<<"\n\n\t\tFUNCTION OVERLOADING:Function overloading is the \
process by\n\nwhich we can use many functions with a single name where they a\
re different\n\nbased on their argument type or argument name.Here return\
 type has no effect.It\n\nis an important feature of OOP.\n\n\n\t\t * Press a\
ny Key To Go To Back Page *";getch();
      function_overloading();          break;
   case 2:clrscr();
      cout<<"\n\n\tSometimes we may need similar type of funtion differen\
ciang only\n\nfunction parameter type or number of arguments.In such situati\
ion we will use\n\nfunction overloading.Besides funtion overloading is widel\
y used to handle class\n\nobjects such as overloading constructor funtion.\n\
\n\n\t\t * Press Any Key To Go To Back Page *";getch();
      function_overloading();               break;
   case 3:clrscr();
      cout<<"\n\n\t\treturn_type  function_name(argument_list)\n\n\t\t{\
\n\n\t\t  //body of funtion\n\n\t\t}\n\n\t\treturn_type  same_function_name\
(argument_list)\n\n\t\t{\n\n\t\t  //body of funtion\n\n\t\t}\n\n\t\t  //Defi\
nation of function as many needed.\n\n\n\t\t * Press Any Key To Go To Back Pa\
ge *";    getch();
      function_overloading();                break;
   case 4:start:
      clrscr();
      cout<<"\n\t\t#include<iostream.h>\n\n\t\t\
int add(int a,int b)                       \n\n\t\t\
 {                                         \n\n\t\t\
   return a+b;                             \n\n\t\t\
 }                                         \n\n\t\t\
int add(int x,int y,int z)                 \n\n\t\t\
 {                                         \n\n\t\t\
  return x+y+z;                            \n\n\t\t\
 }                                         \n\n\t\t\
void main()                                \n\n\t\t\
 {                                         \n\n\t\t\
  int a,b,c;                               \n\n\t\t\                   \n\n\t\t\
  cout<<\"enter value for a,b,c:\";        \n\n\t\t\
  cin>>a>>b>>c;                            \n\n\t\t\
  cout<<\"add(a,b)=\"<<add(a,b)<<endl;     \n\n\t\t\
  cout<<\"add(a,b,c)=\"<<add(a,b,c)<<endl;  \n\t\t\t\
  }";
  cout<<"\n\n\n\t\tEnter 1 To Go To Back Page.\n\n\n\t\tEnter 2 To Run The\
 Program.\n\n\n\t\t  **Enter Your Choice:";
   int a;
   cin>>a;
   switch(a)
  {
   case 1:function_overloading();        break;
   case 2:clrscr();
      cout<<"\n\n\t\t\t OUTPUT\n\t\t\t---------\n\n";
      cout<<"\n\n\t\tenter value for a,b,c:\n";
      cout<<"\t\tadd(10,20)="<<add(10,20)<<endl;
      cout<<"\t\tadd(10,20,30)="<<add(10,20,30)<<endl;
      cout<<"\n\n\t\t * Press Any Key To Go To Back Page *"; getch();
      goto start;
   }
    case 5:clrscr();
       f_page();                   break;

  }
  getch();
  }

 //========================Default Parameter=============================\\
 //-----------------------------------------------------------------------\\

 int area(int l,int w=0)   {
   if(w==0)
    return l*l;
   else
    return w*l;
 }

 void assignment::default_parameter()
 {
  clrscr();
  cout<<"\n\n\t\t\t : DEFAULT PARAETER :\n\t\t\t======================\n\n\t\
\t1. What is it ?\n\n\t\t2. Why used ?\n\n\t\t3. General format.\n\n\t\t4.\
Example.\n\n\t\t5. Press 5 To Return Front Page.\n\n\n\t\tEnter Your Choice:";
  int a;
  cin>>a;
  switch(a)
 {
  case 1:clrscr();
     cout<<"\n\n\tIn object oriented programming we can use some initial\
 value to the\n\nformal parameter of a function.when we call that funtion wi\
th missing those\n\nparameter which is given a default value,programme will\
 work with that default\n\nvalue.this type of parameter is called default p\
 arameter.\n\n\n\t\t * Press Any Key To Go To Back Page *"; getch();
     default_parameter();   break;
  case 2:clrscr();
     cout<<"\n\n\tWe default parameter in related to function overloadi\
ng,that means\n\nsometimes we can use default parameter insted of function\
 over loading.Besides\n\nwe use default parameter to combine similar funct\
 ion into one.we also use\n\ndefault parameter to add new parameter to exi\
 sting function.\n\n\n\t\t * Press Any Key To Go To Back Page * "; getch();
     default_parameter();    break;
  case 3:clrscr();
     cout<<"\n\n\n   ret_type fun_name(data_type var1=def_value,...,dat\
a_type varn=def_value);\n\n\n\t\t * Press Any Key To Go To Back Page *";
     getch();
     default_parameter();    break;
  case 4:start:
     clrscr();
     cout<<"\n\t\t#include<iostream.h>      \n\n\n\t\t\
int area(int l,int w=0)   {                           \n\n\t\t\
   if(w==0)                                           \n\n\t\t\
    return l*l;                                       \n\n\t\t\
   else                                               \n\n\t\t\
    return w*l;                                       \n\n\t\t\
 }                                                    \n\n\t\t\
void main() {                                         \n\n\t\t\
  int w,h;                                            \n\n\t\t\
  cout<<\"enter wide and height\\n\";                 \n\n\t\t\
  cin>>w>>h;                                          \n\n\t\t\
  cout<<\"area of rectangle= \"<<area(w,h)<<endl;     \n\n\t\t\
  cout<<\"area of squre= \"<<area(w);                 \n\n\t\t\
 }          ";
   cout<<"\n\n\n\t\tEnter 1 To Go To Back Page.\n\n\n\t\tEnter 2 To Run The\
 Program.\n\n\n\t\t  **Enter Your Choice:";
   int a;
   cin>>a;
   switch(a)
  {
   case 1:default_parameter();   break;
   case 2:clrscr();
      cout<<"enter wide and height\n10 12\n";
      cout<<"area of rectangle= "<<area(10,12)<<endl;
      cout<<"area of squre= "<<area(10);
      cout<<"\n\n\n\t\t * Press Any Key To Go To Back Page *"; getch();
      goto start;
   }
   case 5:clrscr();
      f_page();        break;
  }
   getch();
  }


 //=================================Main Function=========================\\
 //-----------------------------------------------------------------------\\


 void main(void)
 {
  clrscr();
  assignment a;
  a.f_page();
 }


 //==================================END==================================\\
 //-----------------------------------------------------------------------\\

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........

Departmental Store Management System.

#include<iostream.h>
#include<conio.h>
const int m=20;
  class dept
  {   int amount[m],pris[m],k,a,b,amount1;
      int code,code1,cod[m],s,last;
    public:
       float price,price1;
       dept(void);
       void sell(void);
       void total_items(void);
       void add_old(void);
       void add_new(void);
       void show(void);
     };
    dept:: dept(void)
    { s=0;a=10;b=40;last=5;amount[0]=0;
      for(int k=0;k<last;k++)
      { s=s+1;b=b+10;
      cod[k]=s;
      amount[k]=a;
      pris[k]=b;
      }
     }
   void dept::add_old(void)
    { cout<<"\nEnter item code:";
      cin>>code1;
      cout<<"\nEnter item price:";
      cin>>price1;
     for(k=0;k<last;k++)
       { if(code1==cod[k])
      { a=a+1;
        amount[k]=a;
        pris[k]=price1;
      }
       //    else
     //cout<<"\nSorry..This item is not available.\n";
       }
      }
   void dept::add_new(void)
   {    cout<<"\nEnter item code:";
    cin>>code1;
    cout<<"\nEnter amount of that item:";
    cin>>amount1;
    cout<<"\nEnter item price:";
    cin>>price1;

    cod[last]=code1;
    amount[last]=amount1;
    pris[last]=price1;
    last++;
     }
    void dept::show(void)
     { for(k=0;k<last;k++)
    {
      cout<<"\nCODE:"<<cod[k]<<"\t";
      cout<<"\nAMOUNT:"<<amount[k]<<"\t";
      cout<<"\nPRICE:"<<pris[k]<<endl;
      }
    }
  void dept::sell(void)
   {
    cout<<"\nEnter product code:\n";
    cin>>code;
    cout<<"\nEnter product price:\n";
    cin>>price;
    }
  void dept::total_items(void)
   {
     cout<<"\n\nITEM CODE:"<<code<<"\n\nITEM PRICE:"<<price;
   }
  int main()
  {
     dept d[10];
     static int j=0;
     int x,i=0,p,s=0;
    clrscr();
    do{
       cout<<"\nENTER YOUR CHOICE:\n";
       cout<<"\n1. Show all stored items:";
       cout<<"\n2. Add an old item:";
       cout<<"\n3. Add a new item:";
       cout<<"\n4. Sell an item:";
       cout<<"\n5. Total sold:";
       cout<<"\n6. Show total items sold:";
       cout<<"\n7. Quit";

      cin>>x;
    switch(x)
    {   case 1: d[i].show();
            break;
        case 2: d[i].add_old();
            d[i].show();
            break;
        case 3: d[i].add_new();
            d[i].show();
            break;
        case 4: d[i].sell();
            i++,j++;
            break;
        case 5:{ cout<<"Total Sold:";
             s=0;

             for(p=0;p<j;p++)
             { s=s+d[p].price;
             }
             cout<<s;
             cout<<"TK.\n";
             }
             break;
        case 6: for(i=0;i<j;i++)
              {  d[i].total_items();
               }
              break;
        case 7: break;
         }
         } while(x!=7);
          getch();
          return 0;
       }

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........

Banking Management System.

    #include<iostream.h>
    #include<stdio.h>
    #include<conio.h>

    class bank
    {
     private:

     int ac_no,account;
     float balance;
     char name[20];

     public:
     void open(void);
     void deposite(int);
     void withdraw(int);
     void search(int);
     void display(void);

    };

    void bank::open(void)

     {
         cout<<"ENTER YOUR NAME :  ";
         cin>>name;
         cout<<"ENTER YOUR ACCOUNT NUMBER :  ";
         cin>>account;
         cout<<"ENTER THE AMOUNT OF MONEY : BDT  ";
         cin>>balance;
     }

          void bank::deposite(int j)

    {
          int bnc;

          if(account==j)

       {
        cout<<"ENTER THE AMOUNT OF MONEY : BDT ";
        cin>>bnc;
        balance=balance+bnc;
        cout<<"\n\n\tJOB HAS DONE WELL !!! \n";
       }


    }

    void bank::withdraw(int k)
    {
           int blnc,p;

      if(account==k)

      {
        cout<<"YOUR CURRENT ACCOUNT BALANCE IS BDT "<<balance<<"\n"<<"THE AMOUNT OF MONEY YOU WANT TO WITHDRAW IS BDT ";
        cin>>blnc;
           p=balance-blnc;
           { if(p<0)
              cout<<"SORRY !!! THERE IS NOT ENOUGH MONEY IN YOUR ACCOUNT\n";
            else if(p>=0)
              {
                cout<<"\n\tYOUR REQUEST TO WITHDRAW MONEY HAS DONE\n\n";
                balance=p;
              }

           }
       }

    }


    void bank::display(void)
    {    cout<<"\n\nNAME : "<<name<<"\n\nACCOUNT NO. "<<account<<"\n\nBALANCE : BDT "<<balance<<"\n\n";
    }



    void bank::search(int m)

    {

     if(account==m)
       {
         cout<<"\n\n*******Account Holder's INFO*******";
         cout<<"\n\nNAME : "<<name<<"\n\nACCOUNT NO. "<<account<<"\n\nBALANCE : BDT "<<balance<<"\n\n";
         cout<<"\n***************************************\n\n";
       }

    }

       void main()
       {
      int i,j,k,m,l,y=0;
         bank b[20];
        int index;
              textcolor(0);
             textbackground(4);
            clrscr();

          do
        {
    cout<<"\a\nPRESS 1 TO OPEN ACCOUNT\n\n"<<"PRESS 2 TO DEPOSITE AMOUNT\n\n"<<"PRESS 3 TO WITHDRAW MONEY \n\n"<<"PRESS 4 TO DISPLAY \n\n"<<"PRESS 5 TO SEARCH \n\n"<<"PRESS 6 TO EXIT \n\n\t\n";
    cout<<"Your option......";

    cin>>index;
               switch(index)
            {
               case 1:
                 cout<<"\nHOW MANY ACCOUNT YOU WANT TO OPEN?\n"; //opening account
                 cin>>y;
                  for(i=0;i<y;i++)
                b[i].open();
               break;
              case 2:
                 cout<<"\nENTER YOUR ACCOUNT NO. ";             //deposite amount
                 cin>>j;
                 for(i=0;i<y;i++)
                  {
                    b[i].deposite(j);
                  }
              break;
              case 3:
                cout<<"\nENTER YOUR ACCOUNT NO. ";              //withdraw money
                cin>>k;
                for(i=0;i<y;i++)
                   {
                   b[i].withdraw(k);
                   }
                break;

              case 4:
                for(i=0;i<y;i++)
                  {                                             //display option
                  b[i].display();
                  }
                break;
              case 5:
                cout<<"\nENTER YOUR ACCOUNT NO. ";              //search option
                cin>>m;
                 for(i=0;i<y;i++)
                {
                b[i].search(m);
                }
                 break;
             case 6:
             break;

                default:cout<<"\nYOU HAVE PRESSED THE WRONG KEY. PLEASE TRY AGAIN. \n\n\n";
                break;
            }
           }     while(index!=6);
    }

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........

Banking Management System.

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <fstream.h>


class cus
{
  public:
  char name[20];
  float blnc;
  int ac_no;
  void input();

};


void cus::input()
{

  cout<<"\n\nname:";
 cin>>name;
 cout<<"\n\naccount no:";
 cin>>ac_no;
 cout<<"\n\n balance:";
 cin>>blnc;


};

///////////////////////////////

class acc:public cus
{
public:
float intrst;
int tim;
void add();
void output();
acc();
};

acc::acc()
{
tim=0;
intrst=0;
}

void acc::output()
{
 cout<<"\n\nname:"<<name;
 cout<<"\n\n total balance:"<<blnc;
 cout<<"\n\ninterest:"<<intrst;
}


void acc::add()
{
 int i;
 tim++;
 cout<<"\n\n Amount:";
 cin>>i;
 intrst=intrst+blnc*tim*.07;
 blnc=blnc+intrst+i;

};

class loan:public acc
{
public:
float lon;
loan()
{
lon=0;
}
void payloan();
void getloan();
};


void loan::getloan()
{
  int l;
  if(lon==0)
  {
    cout<<"Enter loan:";
    cin>>l;
    if(l<=(l*1.50))
    {
    cout<<"\n\n\tyou can get loan";
    lon=l+l*0.1;
    }

    else
    {
     cout<<"\n \n\tSorry.";
     lon=0;
    }
    }
    else
     cout<<"\n\n\tYou have previous loan.";
}


void loan::payloan()
{
  int m;
  if(lon==0)
  cout<<"\n\n\t You have no loan.";
  else
  {
    cout<<"\n\n\t You have to pay "<<lon;
    cout<<"\n\nEnter your payment";
    cin>>m;
    lon=lon-m;
    if(lon<=0)
    {
    cout<<"\n\n\tok your loan paid.";
    lon=0;
    }
    else
    cout<<"loan to be paid="<<lon;
}
}

void show()
{
 loan a;
 int i,found=0;
 fstream file;

 file.open("final.text",ios::ate|ios::in|ios::out|ios::binary);
 file.seekg(0);

 cout<<"\n\nInsert account no:";
 cin>>i;
 for(;;)
 {
    file.read((char*)&a,sizeof(a));
    if(!file)
    break;

 if(i==a.ac_no)
 {
  a.output();
  found=1;
  break;
 }
 }
 if(found!=1)
  cout<<"\nNot exist.";
  file.close();

 getch();
};

void add_a()
{
 loan a;
 fstream file;
 int i,k,found=0;
 cout<<"\n\nInsertaccount no:";
 cin>>i;
 file.open("final.text",ios::ate|ios::in|ios::out|ios::binary);
 file.seekg(0);
 for(k=0;;k++)
 {
     file.read((char*)&a,sizeof(a));
     if(!file)
     break;
    if(i==a.ac_no)
    {
     a.add();
     found=1;

     break;
    }

 }
 if(found==1)
 {
 cout<<" K="<<k;
  int d=sizeof(a);
  cout<<"OBject="<<d;
  int n=k*sizeof(a );
    file.seekp(n);
  file.write((char*)&a,sizeof(a));
  cout<<"\n\n\tInformation added to file.";
  file.close();
 }
 else
  cout<<"\n\n\t This account is not exist in file.";

 getch();

};


void dlt()
{
loan a[100];
 fstream file;
  file.open("final.text",ios::ate|ios::in|ios::out|ios::binary);

 int i,l,found=0;
 cout<<"\n\n insert account no:";
 cin>>i;
 file.seekg(0);

 for(int k=0;;k++)
 {
     file.read((char*)&a[k],sizeof(a[k]));
      if(!file)
      break;

  }
 file.close();
 file.open("final.text",ios::out|ios::binary);
  for(l=0;l<k;l++)
 {
    if(i==a[l].ac_no)
    {
     cout<<"\n\n\t Record deleted.";
     found=1;
    }
    else
     file.write((char*)&a[l],sizeof(a[l]));

  }
    if(found==0)
    cout<<"\n\n\t Record is not in file.";
    file.close();
  getch();


};


void loanf()
{
 loan a;
 fstream file;
 file.open("final.text",ios::ate|ios::in|ios::out|ios::binary);
  int i,found=0;
 cout<<"\n\naccount no:";
 cin>> i;
 file.seekg(0);
 for(int k=0;;k++)
 {
        file.read((char*)&a,sizeof(a));
        if(!file)
      break;

    if(i==a.ac_no)
    {
    a.getloan();
    int n=k*sizeof(a);
    file.seekp(n);
    file.write((char*)&a,sizeof(a));
    found=1;
    break;

    }
    }
    file.close();
        if(found==0)
         cout<<"\n\n\t This account is not exist in file.";

 getch();
};

void pay()
{
loan a;
 fstream file;
 file.open("final.text",ios::ate|ios::in|ios::out|ios::binary);

 int i,found=0;
 cout<<"Account no:";
 cin>>i;
 file.seekg(0);

 for(int k=0;;k++)
 {file.read((char*)&a,sizeof(a));
    if(!file)
      break;

 if(i==a.ac_no)
 {
 a.payloan();
 int n=k*sizeof(a);
    file.seekp(n);
    file.write((char*)&a,sizeof(a));
    found=1;
    break;
 }
 }
 if(found==0)
 {
 cout<<"\n\n\t This account is not exist in file.";
 }
 file.close();

 getch();
};


void inputdata(loan a)
{
 fstream file;

 file.open("final.text",ios::ate|ios::in|ios::out|ios::binary);
 file.seekp(0,ios::end);
 file.clear();
 file.write((char*)&a,sizeof(a));
 file.close();

 }



/////////////MAIN PROGRAM//////////////////

int main()
{
     int i;


 for(;;)
 {
  loan a;
  clrscr();
  cout<<"\n\n\t<<<<<<<<<<<<<<<<<<MENU>>>>>>>>>>>>>>>>>>>>>>>>\n";

          cout<<"________________________________________________\n";
          cout<<"________________________________________________\n" ;
          cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n";
  cout<<"\n\n\n\n\t 1.input. \n\n\t 2.output\n\n\t 3.Add\n\n\t 4.Delete\n\n\t  5.loan\n\n\t 6.pay\n\n\t7.Exit\n\n\t  your choice:";
  cin>>i;
  switch(i)
  {
    case 1:a.input();inputdata(a);
             break;
    case 2:show();
    break;
    case 3:add_a();
    break;
    case 4:dlt();
    break;

    case 5:loanf();
    break;
     case 6:pay();
    break;
     default:exit(0);
  }
 }
// return 0;
}

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........

Football Players Position Information.

#include<conio.h>
#include<fstream.h>
#include<string.h>

class footballer{

         protected:

         char id[10],name[30];
         int per;

         public:

         footballer(){per =100;}
         void getid()
         {
          cout<<"input footballer id ";
          cin>>id;
          cout<<"input fottballer name";
          cin>>name;
         };


         };

class fileinfoot:public footballer{

                     public:
                     void fil()
                     {
                      fstream x("FOOTBALL.txt",ios::out|ios::app);
                      x.width(30);
                      x<<endl;
                      x<<name;
                      x.width(20);
                      x<<id;
                      x.close();

                     }

} ;
class goalkeeper: public fileinfoot{
                    int save;
                    int loss;
                    public:
                   void performance()
                   {
                    getid();
                    cout<<"\nHow many goal he saved?\n";
                    cin>>save;
                    save=save*25;
                    cout<<"\nHow many goal he got\n;";
                    cin>>loss;
                    loss=loss*75;
                    per=per+save-loss;
                    if(per<0)
                    per=0;
                    file();
}
void file();


};

      void  goalkeeper::file()
                 {
                  char fil[20];
                  strcpy(fil,id);
                  strcat(fil,".txt");
                  ofstream x(fil);
                  x<<"NAME:-"<<name<<endl;
                  x<<"ID:-"<<id<<endl;
                  x<<"POSITION- GOALKEEPER\n";
                  x<<"Performance point:-"<<per<<endl;
                  x.close();
                       fstream y("GOALKEEP.txt",ios::out|ios::app);
                      y<<endl;
                      y.width(30);
                      y<<name;
                      y.width(20);
                      y<<id;
                      y.close();


                 }

class defender: public fileinfoot{
                    int defend;
                    int loss;
                    public:
                   void performance()
                   {
                    getid();
                    cout<<"\nHow many defend?\n";
                    cin>>defend;
                    defend=defend*25;
                    cout<<"\nHow many missdefence\n;";
                    cin>>loss;
                    loss=loss*5;
                    per=per+defend-loss;
                    if(per<0)
                    per=0;

                    file();
                   }
                   void file();

};
 void defender::file()
                 {
                  char fil[20];
                  strcpy(fil,id);
                  strcat(fil,".txt");
                  ofstream x(fil);
                  x<<"NAME:-"<<name<<endl;
                  x<<"ID:-"<<id<<endl;
                  x<<"POSITION- DEFENDER\n";
                  x<<"Performance point:-"<<per<<endl;
                  x.close();
                       fstream y("DEFENDER.txt",ios::out|ios::app);
                      y<<endl;
                      y.width(30);
                      y<<name;
                      y.width(20);
                      y<<id;
                      y.close();
                 }

class midfielder:public fileinfoot{
                     int passing;
                    int mispass;
                    public:
                   void performance()
                   {getid();
                    cout<<"\nHow many pass?\n";
                    cin>>passing;
                    passing=passing*25;
                    cout<<"\nHow many miss pass\n;";
                    cin>>mispass;
                    mispass=mispass*75;
                    per=per+passing-mispass;
                    if(per<0)
                    per=0;
                    file();
                   }
                    void file();

};
 void midfielder:: file()
                 {
                  char fil[20];
                  strcpy(fil,id);
                  strcat(fil,".txt");
                  ofstream x(fil);
                  x<<"NAME:-"<<name<<endl;
                  x<<"ID:-"<<id<<endl;
                  x<<"POSITION- MIDFIELDER\n";
                  x<<"Performance point:-"<<per<<endl;
                  x.close();
                   fstream y("MIDFIELD.txt",ios::out|ios::app);
                      y<<endl;
                      y.width(30);
                      y<<name;
                      y.width(20);
                      y<<id;
                      y.close();



                 }

class striker: public fileinfoot{
                    int goal;
                    int loss;
                public:
                   void performance()
                   {getid();
                    cout<<"\nHow many goal?\n";
                    cin>>goal;
                    goal=goal*25;
                    cout<<"\nHow many goal he miss\n;";
                    cin>>loss;
                    loss=loss*75;
                    per=per+goal-loss;
                    if(per<0)
                    per=0;
                    file();
                   }
                    void file();

};
 void striker:: file()
                 {
                  char fil[20];
                  strcpy(fil,id);
                  strcat(fil,".txt");
                  ofstream x(fil);
                  x<<"NAME:-"<<name<<endl;
                  x<<"ID:-"<<id<<endl;
                  x<<"POSITION- STRIKER\n";
                  x<<"Performance point:-"<<per<<endl;
                  x.close();
                  fstream y("STRIKER.txt",ios::out|ios::app);
                      y<<endl;
                      y.width(30);
                      y<<name;
                      y.width(20);
                      y<<id;
                      y.close();
                 }



class add{
         public:
         add();
         };
     add::add(){
          goalkeeper g;
          defender d;
          striker s;
          midfielder m;
          int co;
          while(1)
          {clrscr();
          cout<<"\n1...goalkeeper\n2...defender\n3...striker\n4...midfielder\n5...exit\n";
          cin>>co;
          if(co==5)
          break;
          if(co==1)
          {
        g.performance();
        g.fil();
          }
           if(co==2)
          { d.performance();
           d.fil();
           }
           if(co==3)
           {
           s.performance();
           s.fil();
           }
           if(co==4)
           {
           m.performance();
           m.fil();
          }
          }
         }




class search{

public:
void find();
} ;
void search::find(){
            int i;
            char id[20],c;
            while(1)
            {
             clrscr();
            cout<<"1...ALL FOOTBALLER\n2...ALL GOALKEEPER\n3...ALL DEFENDER\n";
            cout<<"4...ALL MIDFIELDER\n5...ALL STRIKER\n6...SEARCH BY ID\n7...Exit";
            cin>>i;
            if(i==7)
            break;
            if(i==1)
            {
            ifstream x("FOOTBALL.txt");
            cout<<"FOOTBALLERS NAME AND ID \n\n";
            while(x)
             { x.get(c);
               cout<<c;
              }
              getch();
              x.close();
          }
          if(i==2)
          {ifstream x("GOALKEEP.txt");
           cout<<"FOOTBALLERS NAME AND ID \n\n";
           while(x)
           { x.get(c);
             cout<<c;
           }
           getch();
           x.close();
          }
          if(i==3)
          {ifstream x("DEFENDER.txt");
           cout<<"DEFENERS NAME AND ID \n\n";
           while(x)
           { x.get(c);
             cout<<c;
           }
           getch();
           x.close();
          }
          if(i==4)
          {ifstream x("MIDFIELD.txt");
           cout<<"MIDFIELDERS NAME AND ID \n\n";
           while(x)
           { x.get(c);
             cout<<c;
           }
           getch();
           x.close();
          }
          if(i==5)
          {ifstream x("STRIKER.txt");
           cout<<"STRIKER NAME AND ID \n\n";
           while(x)
           { x.get(c);
             cout<<c;
           }
           getch();
           x.close();
          }
          if(i==6)
          {clrscr();
           cout<<"input the id";
           cin>>id;
           char fil[20];
          strcpy(fil,id);
           strcat(fil,".txt");
           ifstream x(fil);
            while(x)
           { x.get(c);
             cout<<c;
           }
           getch();
           x.close();
          }
          }

}


int main()
{
  int c;
 clrscr();

 while(1)
 {
  clrscr();
  cout<<"1...add\n2...search\n3...exit\n\n";
  cin>>c;
  if(c==3)
     break;
  else if(c==1)
     {
      add a;
     }
  else if(c==2)
     {
     search f;
     f.find();
     }

 }


 return 0;
}

///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........