Tuesday 17 May 2011

Project on Game using C++

#include <iostream>
 #include <cstdlib>
 #include<ctime>
 #include <string>
#include<conio.h>
 const int MAX_TRIES=5;
 int letterFill (char, string, string&);
void main ()
 {
 string name;
 char letter;
 int num_of_wrong_guesses=0;
 string word;
 string words[] =
 {
  "india",
  "pakistan",
  "nepal",
  "malaysia",
  "philippines",
  "australia",
  "iran",
  "ethiopia",
  "oman",
  "indonesia"
 };
 //choose and copy a word from array of words randomly
 srand(time(NULL));
 int n=rand()% 10;
 word=words[n];
  
 // Initialize the secret word with the * character.
 string unknown(word.length(),'*');
clrscr();
 // welcome the user
 cout << "\n\nWelcome to hangman...Guess a country Name";
 cout << "\n\nEach letter is represented by a star.";
 cout << "\n\nYou have to type only one letter in one try";
 cout << "\n\nYou have " << MAX_TRIES << " tries to try and guess the word.";
 cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
  
 // Loop until the guesses are used up
 while (num_of_wrong_guesses < MAX_TRIES)
 {
  cout << "\n\n" << unknown;
  cout << "\n\nGuess a letter: ";
  cin >> letter;
  // Fill secret word with letter if the guess is correct,
  // otherwise increment the number of wrong guesses.
  if (letterFill(letter, word, unknown)==0)
  {
   cout << endl << "Whoops! That letter isn't in there!" << endl;
   num_of_wrong_guesses++;
  }
  else
  {
   cout << endl << "You found a letter! Isn't that exciting!" << endl;
  }
  // Tell user how many guesses has left.
  cout << "You have " << MAX_TRIES - num_of_wrong_guesses;
  cout << " guesses left." << endl;
  // Check if user guessed the word.
  if (word==unknown)
  {
   cout << word << endl;
   cout << "Yeah! You got it!";
   break;
  }
 }
 if(num_of_wrong_guesses == MAX_TRIES)
 {
  cout << "\nSorry, you lose...you've been hanged." << endl;
  cout << "The word was : " << word << endl;
 }
 cin.ignore();
 cin.get();
 return 0;
 }
 /* Take a one character guess and the secret word, and fill in the
  unfinished guessword. Returns number of characters matched.
  Also, returns zero if the character is already guessed. */
 int letterFill (char guess, string secretword, string &guessword)
 {
 int i;
 int matches=0;
 int len=secretword.length();
 for (i = 0; i< len; i++)
 {
  // Did we already match this letter in a previous guess?
  if (guess == guessword[i])
   return 0;
  // Is the guess in the secret word?
  if (guess == secretword[i])
  {
   guessword[i] = guess;
   matches++;
  }
 }
 return matches;
 }
 Output:-

C++ project on SCHOOL MANAGEMENT

#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;

class student
{
int rollno;
char name[50];
int p_marks, c_marks, m_marks, e_marks, cs_marks;
double per;
char grade;
void calculate(); //function to calculate grade
public:
void getdata();  //function to accept data from user
void showdata() const; //function to show data on screen
void show_tabular() const;
int retrollno() const;
}; //class ends here


void student::calculate()
{
per=(p_marks+c_marks+m_marks+e_marks+cs_marks)/5.0;
if(per>=60)
  grade='A';
else if(per>=50)
  grade='B';
else if(per>=33)
  grade='C';
else
  grade='F';
}

void student::getdata()
{
cout<<"\nEnter The roll number of student ";
cin>>rollno;
cout<<"\n\nEnter The Name of student ";
cin.ignore();
cin.getline(name,50);
cout<<"\nEnter The marks in physics out of 100 : ";
cin>>p_marks;
cout<<"\nEnter The marks in chemistry out of 100 : ";
cin>>c_marks;
cout<<"\nEnter The marks in maths out of 100 : ";
cin>>m_marks;
cout<<"\nEnter The marks in english out of 100 : ";
cin>>e_marks;
cout<<"\nEnter The marks in computer science out of 100 : ";
cin>>cs_marks;
calculate();
}

void student::showdata() const
{
cout<<"\nRoll number of student : "<<rollno;
cout<<"\nName of student : "<<name;
cout<<"\nMarks in Physics : "<<p_marks;
cout<<"\nMarks in Chemistry : "<<c_marks;
cout<<"\nMarks in Maths : "<<m_marks;
cout<<"\nMarks in English : "<<e_marks;
cout<<"\nMarks in Computer Science :"<<cs_marks;
cout<<"\nPercentage of student is  :"<<per;
cout<<"\nGrade of student is :"<<grade;
}

void student::show_tabular() const
{
cout<<rollno<<setw(6)<<" "<<name<<setw(10)<<p_marks<<setw(4)<<c_marks<<setw(4)<<m_marks<<setw(4)
  <<e_marks<<setw(4)<<cs_marks<<setw(8)<<per<<setw(6)<<grade<<endl;
}

int  student::retrollno() const
{
return rollno;
}

void write_student(); //write the record in binary file
void display_all(); //read all records from binary file
void display_sp(int); //accept rollno and read record from binary file
void modify_student(int); //accept rollno and update record of binary file
void delete_student(int); //accept rollno and delete selected records from binary file
void class_result(); //display all records in tabular format from binary file
void result();  //display result menu
void intro();  //display welcome screen
void entry_menu(); //display entry menu on screen

int main()
{
char ch;
cout.setf(ios::fixed|ios::showpoint);
cout<<setprecision(2); // program outputs decimal number to two decimal places
intro();
do
{
  system("cls");
  cout<<"\n\n\n\tMAIN MENU";
  cout<<"\n\n\t01. RESULT MENU";
  cout<<"\n\n\t02. ENTRY/EDIT MENU";
  cout<<"\n\n\t03. EXIT";
  cout<<"\n\n\tPlease Select Your Option (1-3) ";
  cin>>ch;
  switch(ch)
  {
   case '1': result();
    break;
   case '2': entry_menu();
    break;
   case '3':
    break;
   default :cout<<"\a";
  }
    }while(ch!='3');
return 0;
}

void write_student()
{
student st;
ofstream outFile;
outFile.open("student.dat",ios::binary|ios::app);
st.getdata();
outFile.write(reinterpret_cast<char *> (&st), sizeof(student));
outFile.close();
    cout<<"\n\nStudent record Has Been Created ";
cin.ignore();
cin.get();
}

void display_all()
{
student st;
ifstream inFile;
inFile.open("student.dat",ios::binary);
if(!inFile)
{
  cout<<"File could not be open !! Press any Key...";
  cin.ignore();
  cin.get();
  return;
}
cout<<"\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n";
while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
{
  st.showdata();
  cout<<"\n\n====================================\n";
}
inFile.close();
cin.ignore();
cin.get();
}

void display_sp(int n)
{
student st;
ifstream inFile;
inFile.open("student.dat",ios::binary);
if(!inFile)
{
  cout<<"File could not be open !! Press any Key...";
  cin.ignore();
  cin.get();
  return;
}
bool flag=false;
while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
{
  if(st.retrollno()==n)
  {
   st.showdata();
   flag=true;
  }
}
inFile.close();
if(flag==false)
  cout<<"\n\nrecord not exist";
cin.ignore();
cin.get();
}

void modify_student(int n)
{
bool found=false;
student st;
fstream File;
File.open("student.dat",ios::binary|ios::in|ios::out);
if(!File)
{
  cout<<"File could not be open !! Press any Key...";
  cin.ignore();
  cin.get();
  return;
}
    while(!File.eof() && found==false)
{

  File.read(reinterpret_cast<char *> (&st), sizeof(student));
  if(st.retrollno()==n)
  {
   st.showdata();
   cout<<"\n\nPlease Enter The New Details of student"<<endl;
   st.getdata();
      int pos=(-1)*static_cast<int>(sizeof(st));
      File.seekp(pos,ios::cur);
      File.write(reinterpret_cast<char *> (&st), sizeof(student));
      cout<<"\n\n\t Record Updated";
      found=true;
  }
}
File.close();
if(found==false)
  cout<<"\n\n Record Not Found ";
cin.ignore();
cin.get();
}

void delete_student(int n)
{
student st;
ifstream inFile;
inFile.open("student.dat",ios::binary);
if(!inFile)
{
  cout<<"File could not be open !! Press any Key...";
  cin.ignore();
  cin.get();
  return;
}
ofstream outFile;
outFile.open("Temp.dat",ios::out);
inFile.seekg(0,ios::beg);
while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
{
  if(st.retrollno()!=n)
  {
   outFile.write(reinterpret_cast<char *> (&st), sizeof(student));
  }
}
outFile.close();
inFile.close();
remove("student.dat");
rename("Temp.dat","student.dat");
cout<<"\n\n\tRecord Deleted ..";
cin.ignore();
cin.get();
}

void class_result()
{
student st;
ifstream inFile;
inFile.open("student.dat",ios::binary);
if(!inFile)
{
  cout<<"File could not be open !! Press any Key...";
  cin.ignore();
  cin.get();
  return;
}
cout<<"\n\n\t\tALL STUDENTS RESULT \n\n";
cout<<"==========================================================\n";
cout<<"R.No       Name        P   C   M   E   CS   %age   Grade"<<endl;
cout<<"==========================================================\n";
while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
{
  st.show_tabular();
}
cin.ignore();
cin.get();
inFile.close();
}

void result()
{
char ch;
int rno;
system("cls");
cout<<"\n\n\n\tRESULT MENU";
cout<<"\n\n\n\t1. Class Result";
cout<<"\n\n\t2. Student Report Card";
cout<<"\n\n\t3. Back to Main Menu";
cout<<"\n\n\n\tEnter Choice (1/2/3)? ";
cin>>ch;
system("cls");
switch(ch)
{
case '1' : class_result(); break;
case '2' : cout<<"\n\n\tEnter Roll Number Of Student : "; cin>>rno;
    display_sp(rno); break;
case '3' : break;
default: cout<<"\a";
}
}

void intro()
{
cout<<"\n\n\n\t\t WELCOME TO STUDENT REPORT CARD PROJECT";
cout<<"\n\n\n\tPress Enter To Continue\n\n";
//cout<<"\n\n\n\tMADE BY : SULABH AGRAWAL";
//cout<<"\n\tSCHOOL : CAMBRIDGE SCHOOL";
cin.get();
}

void entry_menu()
{
char ch;
int num;
system("cls");
cout<<"\n\n\n\tENTRY MENU";
cout<<"\n\n\t1.CREATE STUDENT RECORD";
cout<<"\n\n\t2.DISPLAY ALL STUDENTS RECORDS";
cout<<"\n\n\t3.SEARCH STUDENT RECORD ";
cout<<"\n\n\t4.MODIFY STUDENT RECORD";
cout<<"\n\n\t5.DELETE STUDENT RECORD";
cout<<"\n\n\t6.BACK TO MAIN MENU";
cout<<"\n\n\tPlease Enter Your Choice (1-6) ";
cin>>ch;
system("cls");
switch(ch)
{
case '1': write_student(); break;
case '2': display_all(); break;
case '3': cout<<"\n\n\tPlease Enter The roll number "; cin>>num;
   display_sp(num); break;
case '4': cout<<"\n\n\tPlease Enter The roll number "; cin>>num;
   modify_student(num);break;
case '5': cout<<"\n\n\tPlease Enter The roll number "; cin>>num;
   delete_student(num);break;
case '6': break;
default: cout<<"\a"; entry_menu();
}
}


Output:-



C++ Program To Determine Whether The Seller Made Profit or Loss. Also Determine How Much Profit or Loss He Made


C++ Program To Determine Whether The Seller Made Profit or Loss. Also Determine How Much Profit or Loss He Made
If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.
 Formula: Loss = Cost price (C.P.) – Selling Price (S.P.)
                Profit=Selling Price (S.P.)-Cost price (C.P.)
 Profit or Loss is always calculated on the cost price. Marked price: This is the price marked as the selling price on an article, also known as the listed price
 Here Is A Code And All Three Conditions
#include<iostream>
#include<conio.h>
void main()
{
 float sp,cp,l,p;
 clrscr();
 cout<<"Enter The Selling Price \n\n";
 cin>>sp;

 cout<<"Enter The Cost Price \n\n";
 cin>>cp;

 if(cp>sp)
 {
  l=cp-sp;
  cout<<"\n\nLoss Is = "<<l;
 }
 else if(cp<sp)
 {
  p=sp-cp;
  cout<<"\nProfit Is = "<<p;
 }
 else
 {
  cout<<"\nNo Profit No Loss\n";
 }
 return 0;
}
 Output:-
Enter The Selling Price
500.00
Enter The Cost Price
300.00
Profit: 200

Wednesday 11 May 2011

Project on School Management System using C++

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<fstream.h>
#include<dos.h>
using namespace std;

struct marks_criteria
{
int sc_min,com_min,arts_min, seat_sc, seat_com, seat_arts;
} crit;

struct administrator
{
 char user_name[10];
 char password[10];
}admin;

struct  student
{
char name[20];
int regno,m_eng,m_math,m_sc,m_sst,m_lang;
int pref_code, stream;
// Sc=1, Com=2; Arts=3;


 public:
  void new_file();
  void input_data();
  void allot_stream();
  int get_stream();
  void display();
  int show_per()
  {
   return((m_eng+m_math+m_sc+m_sst+m_lang)/5);
  }

};
void welcome();
void menu();
int verify_password();
void assign_user();
void clear();
void input_criteria();
void read_criteria();
void read_student();
void create_eligible_sc();
void create_eligible_com();
void create_eligible_arts();
void read_eligible_sc();
void read_eligible_com();
void read_eligible_arts();
char * stream_name(int strm);
void select_list( char *in_file, char *out_file);
void thanks();

student s;
 main()
{


//     clrscr();
     welcome();

    // cout<<"welcome";
fstream fin, fout;
fstream fsc, fcom, farts;
int opt=1, ch;

while(opt!=8)
{
 // clrscr();


 clear();
 cout<<"\n\t======================  MAIN   MENU  =======================\n";
 cout<<"\n\t[1] CREATE / MODIFY  ADMISSION  CRITERIA(Administrator only)";
 cout<<"\n\n\t[2] ENTER STUDENT'S DATA ";
 cout<<"\n\n\t[3] ALLOTMENT OF  STREAM";
 cout<<"\n\n\t[4] DISPLAY CRITERIA FOR SELECTION";
 cout<<"\n\n\t[5] DISPLAY ALLOTMENT OF  STUDENT'S STREAM";
 cout<<"\n\n\t[6] DISPLAY ALL  STUDENT'S REGISTERED";
 cout<<"\n\n\t[7] CREATE / DISPLAY MERIT LIST";
 cout<<"\n\n\t[8] QUIT";
 cout<<"\n\t=============================================================\n";
 cout<<"\n\n\t\tEnter your  choice : ";
 cin>>opt;
 switch(opt)
 {
 case 1:
   int p;
   assign_user();
   p=verify_password();
   if(p==0)
   {

    input_criteria();
   }
   else
   {
    cout<<"\n\tU R Not a Valid User.";
    cout<<"\n\tU Dont have the Authority to Create Question Bank. Bye\n\n";
   }
   break;

 case 2:
        int option;
        //clrscr();
        cout<<"\nWhat do u want --\n\n\n\n\n\tCreate  a new student information  file or Append to the existing file?\n\n\t(press 1 for new creation and 2 for appending)";
        cin>>option;
        if(option==1)
        {
    s.new_file();
    }
    else
    {
  s.input_data();
  }
  break;

 case 3:
  //clrscr();
  // read_student();
  fin.open("student" ,ios::in|ios::out);

  fsc.open("elig_sc",ios::out);
  fcom.open("eligcom",ios::out);
  farts.open("eligart",ios::out);

  while(fin.read((char*)& s,sizeof(s)))
  {


    s.allot_stream();

    s.get_stream();

    //if(s.get_stream()==0)
           cout<<"\nApplication Rejected. Not Eligible\n";

    if(s.get_stream()==1)
     fsc.write((char*)& s,sizeof(s));


    if(s.get_stream()==2)
     fcom.write((char*)& s,sizeof(s));

    if(s.get_stream()==3)
     farts.write((char*)& s,sizeof(s));



  }
  fin.close();
  fsc.close();
  fcom.close();
  farts.close();
  cout<<"\n*******************************************";
  cout<<"\n\n\tSTREAM ALLOCATION DONE.";
  cout<<"\n*******************************************";
  break;
 case 4:
  read_criteria();
 // clear();
  cout<<"\n Sc : "<<crit.sc_min;
  cout<<"\n Com : "<<crit.com_min;
  cout<<"\n Sc : "<<crit.arts_min;


  break;

 case 5:

  cout<<"\n Enter 1 for Sc, 2 for Com, 3 for Arts  :  ";
  cin>>ch;
  if (ch==1)
   read_eligible_sc();

  if (ch==2)
   read_eligible_com();
  if (ch==3)
   read_eligible_arts();

  break;
 case 6:         //clrscr() ;
   read_student();
   break;
 case 7:
  {
   char c;
   int k=1;
   cout<<"\n****************************************";
   cout<<"\n****************************************";
   cout<<"\n    M E R I T  L I S T";
   cout<<"\n    ==================";
   cout<<"\n\tEnter 1 for MERIT LIST SCIENCE ";
   cout<<"\n\tEnter 2 for MERIT LIST COMMERCE ";
   cout<<"\n\tEnter 3 for MERIT LIST ARTS \t";
   cout<<"\n****************************************";
   cout<<"\n****************************************"; cin>>k;
   if (k==1)
   {
    select_list("elig_sc","sell_sc");
    fin.open("sell_sc",ios::in);
   }
   if (k==2)
   {
    select_list("eligcom","sellcom");
    fin.open("sellcom",ios::in);
   }
   if (k==3)
   {
    select_list("eligart","sellart");
    fin.open("sellart",ios::in);
   }
   if(k>=1 && k<=3)
   {
    while(fin.read((char*)& s,sizeof(s)))
    {
     s.display();

     cout<<"\n\t Continue (y/n)?";
      cin>>c;
     if(c=='n')
      break;

    }

   }
   fin.close();
   fin.close();
   fin.close();
  break;
  }
 case 8:
    thanks();
     // cout<<"\nTHANKS BYE ";
       // exit(0);
  break;
 }

  }

 }

// END OF WHILE


void assign_user()
{

 strcpy(admin.user_name, "rimi");
 strcpy(admin.password, "rimi");


}
int verify_password()
{
 char u_name[10];
 char u_pwd[10],temp[2];
 int x=1;
 cout<<"\n\n   Enter user name : ";
 cin>>u_name;
 cout<<"\n\n   Enter Password : ";
 cin>>u_pwd;
 x=strcmp(admin.user_name,u_name);
 if (x==0)
 {
  x=strcmp(admin.password,u_pwd);

 }
 cin.getline(temp,2);
 return(x);

}
void student::allot_stream()
{
 int per=(m_eng+m_math+m_sc+m_sst+m_lang)/5;
 read_criteria();

 switch(pref_code)
 {
  case 1:
    if(per>=crit.sc_min)
     stream=pref_code;
    else
     stream=0;

    break;
  case 2:
    if(per>=crit.com_min)
     stream=pref_code;
    else
     stream=0;
    break;
  case 3:
    if(per>=crit.arts_min)
     stream=pref_code;
    else
     stream=0;
    break;
 }
}

int student::get_stream()
{
 return(stream);
}


void input_criteria()
{
 fstream fout;
 fout.open("criteria" ,ios::in|ios::out);
 cout<<"\nEnter  the  required marks for SCIENCE stream(in percentage)";
 cin>>crit.sc_min;
 cout<<"\nEnter  No. of Seats for SCIENCE stream";
 cin>>crit.seat_sc;
 cout<<"\nEnter  the  required marks for COMMERCE stream(in percentage)";
 cin>>crit.com_min;
 cout<<"\nEnter  No. of Seats for COMMERCE stream";
 cin>>crit.seat_com;
 cout<<"\nEnter  the  required marks for ARTS stream(in percentage)";
 cin>>crit.arts_min;
 cout<<"\nEnter  No. of Seats for ARTS stream";
 cin>>crit.seat_arts;
 fout.write((char*)& crit,sizeof(crit));
 fout.close();
}

void read_criteria()
{
 fstream fin;
 fin.open("criteria" ,ios::in);
 fin.read((char*)& crit,sizeof(crit));
 fin.close();

}

void student::input_data()
{     //clrscr();
 fstream fin;
 fin.open("student",ios::app|ios::out);
 char t[2], ans;
 while(1)
 {
 cout<<"\nEnter  the  name of the  student  :  ";
 cin>>name;
 cout<<"\n\nEnter  the roll of the  student  :  ";
 cin>>regno;
 cout<<"\n\nEnter  marks in eng  :  ";
 cin>>m_eng;
 cout<<"\n\nEnter  marks in math  :  ";
 cin>>m_math;
 cout<<"\n\nEnter  marks in science  :  ";
 cin>>m_sc;
 cout<<"\n\nEnter  marks in sst  :  ";
 cin>>m_sst;
 cout<<"\n\nEnter  marks in language  :  ";
 cin>>m_lang;
 cout<<"==================STREAM  PREFERED?================ \n";
 cout<<"\t"<<"[1] for SCIENCE\n";
 cout<<"\t"<<"[2] for COMMERCE\n";
 cout<<"\t"<<"[3] for ARTS ";
 cout<<"\n================================================= \n\tENTER PREFERENCE CODE : ";
 cin>>pref_code;
 stream=-1;
 fin.write((char*)&s,sizeof(s));
 cin.getline(t,2);
 cout<<"\n\tEnter More Student ? (y/n)";
  cin>>ans;
 if (ans=='n')
  break;
 }
 fin.close();
}
void student::new_file()
{     //clrscr();
 fstream fin;
 fin.open("student",ios::out);
 char t[2], ans;
 while(1)
 {
 cout<<"\nEnter  the  name of the  student  :  ";
 gets(name);
 cout<<"\n\nEnter  the roll of the  student  :  ";
 cin>>regno;
 cout<<"\n\nEnter  marks in eng  :  ";
 cin>>m_eng;
 cout<<"\n\nEnter  marks in math  :  ";
 cin>>m_math;
 cout<<"\n\nEnter  marks in science  :  ";
 cin>>m_sc;
 cout<<"\n\nEnter  marks in sst  :  ";
 cin>>m_sst;
 cout<<"\n\nEnter  marks in language  :  ";
 cin>>m_lang;
 cout<<"==================STREAM  PREFERED?================ \n";
 cout<<"\t"<<"[1] for SCIENCE\n";
 cout<<"\t"<<"[2] for COMMERCE\n";
 cout<<"\t"<<"[3] for ARTS ";
 cout<<"\n================================================= \n\tENTER PREFERENCE CODE : ";
 cin>>pref_code;
 stream=-1;
 fin.write((char*)&s,sizeof(s));
 cin.getline(t,2);
 cout<<"\n\tEnter More Student ? (y/n)";
  cin>>ans;
 if (ans=='n')
  break;
 }
 fin.close();
}
void student::display()
{

 cout<<"\n============================================\n";
 cout<<"\n\tNAME  : "<<name;
 cout<<"\n\tREGISTRATION NO. : "<<regno;
 cout<<"\n\tPERCENTAGE OF MARKS : "<<( (m_eng+m_math+m_sc+m_sst+m_lang)/5)<<"%";
 cout<<"\n\tSTREAM APPLIED FOR :  "<<stream_name(pref_code);
       // cout<<"\n\tSTREAM ALLOTED : "<<stream_name(stream);
 cout<<"\n============================================\n";

}

void read_student()
{
 fstream fin;
 char c;
 fin.open("student" ,ios::in);
 while(fin.read((char*)& s,sizeof(s)))
 {
   s.display();
   cout<<"\n\tPress any no. to continue ";
   cin>>c;
   cout<<"\n";
 }
 fin.close();

}



void read_eligible_sc()
{
 char ans;
 fstream fout;
 fout.open("elig_sc",ios::in);
 fout.seekg(0);
 while(fout.read((char*)& s,sizeof(s)))
 {
  s.display();
  cout<<"\n\t Continue (y/n)? ";

  cin>>ans;

  if (ans=='n')
   break;

 }
 fout.close();

}

void read_eligible_com()
{
 char ans;
 fstream fout;
 fout.open("eligcom",ios::in);

 while(fout.read((char*)& s,sizeof(s)))
 {
  s.display();
  cout<<"\n\t Continue (y/n)? ";

  cin>>ans;

  if (ans=='n')
   break;

 }
 fout.close();
}



void read_eligible_arts()
{
  char ans;
 fstream fout;
 fout.open("eligart",ios::in);

 while(fout.read((char*)& s,sizeof(s)))
 {
  s.display();
  cout<<"\n\t Continue (y/n)? ";

  cin>>ans;

  if (ans=='n')
   break;

 }
 fout.close();
}
void clear()
{
// for(int i=1;i< =24;i++)
 // cout<<"\n";
}
char * stream_name(int strm)
{
 switch(strm)
 {
 case -1:
  return("Not assigned");
     // break;
 case 0:
  return("Nill");
      // break;
 case 1:
  return("Science");
   // break;
 case 2:
  return("Commerce");
      // break;
 case 3:
  return("Arts");
     // break;
     default:
  return("None");
 }
}
void select_list( char *in_file, char *out_file)
{
 fstream sel, fin;
 int n=0, i,j;
 student sl[100], t;


  sel.open(out_file, ios::out);
  fin.open(in_file,ios::in);

  while(fin.read((char*)& sl[n],sizeof(s)))
  {
   n++;

  }
  cout<<"\nNo of Eligible Students  = "<<n<<"\n";
  for(i=0;i<n;i++)
  {
   for(j=i+1;j<=n;j++)
   {
    if ( sl[i].show_per()<sl[j].show_per())
    {
     t=sl[j];
     sl[j]=sl[i];
     sl[i]=t;
    }
   }
  }
  for(i=0;i<n;i++)
  {
   sel.write((char*)& sl[i],sizeof(s));
  }
 sel.close();
 fin.close();

}
void welcome()
   {
     //clrscr();
     int z;
  cout<<"\t%%      %%      ";
       cout<<"\n\t%%      %% %%%%%%% %%      %%%%%%  %%%%%% %%%%  %%%% %%%%%%%";
       cout<<"\n\t%%      %% %%      %%      %%      %%  %% %%  %%% %% %%       ";
       cout<<"\n\t%%  %%  %% %%%%%   %%      %%      %%  %% %%  %%% %% %%%%%      ";
       cout<<"\n\t%%  %%  %% %%      %%      %%      %%  %% %%      %% %%           ";
       cout<<"\n\t%%%%%%%%%% %%%%%%% %%%%%%% %%%%%%% %%%%%% %%      %% %%%%%%%     ";
       cout<<"\n\n\t\t\t        $$$$$$$$  $$$$$        ";
       cout<<"\n\t\t\t           $$     $   $      ";
       cout<<"\n\t\t\t           $$     $$$$$    ";

       cout<<"\n\n\n\tCOMPUTER   PROJECT  (********  ON STREAM ALLOCATION  *******)";
   
  cout<<" \n\n\n\t\t     press any number and 'ENTER' to continue: ";
  cin>>z;

    // getch();
    }
    void thanks()
 {     int w;
  //clrscr();
  cout<<"\n\n\n\n\n\n\n\n\n\n\t**********   T H A N K   Y O U   F O R   W O R K I N G   *******";
  cout<<"\n\n\n\n\n\n\n\t\t\t Press Any Number And Then 'ENTER' to exit";
  cin>>w;
 }


Output:-