Tuesday, 18 February 2014

KAUN BANEGA CROREPATI (WHO WANTS TO BE A MILLIONAIRE)

//A PROJECT BY ARPIT CHAWLA ON KBC(KAUN BANEGA CROREPATI).

/* questions and answers are being written in a separate file named QNA.dat
    this source code is just an example and you can set your own questions and answers */



#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<fstream.h>
#include<ctype.h>
//DECLARATION OF GLOBAL ARRAYS, STRINGS AND VARIABLES.
char name[20],address[80],dob[10],fname[20];
int age;
int count1,count2;
int a[5]={20,20,20,20,20};
long double telno;
long money[6]={0,10000,100000,1000000,10000000,50000000};
//DECLARATION OF GLOBAL FUNCTIONS.
void eligibility();
void menu();
void rulnreg();
//CLASS DECLARATION AND DEFINATION TO OPERATE ON PRE-EXISTING FILE.
class question
     {public:
      char ques[100];
      char op1[20];
      char op2[20];
      char op3[20];
      char op4[20];
      char correct[1];
      question()
      {strcpy(ques,"                                                                                                    ") ;
       strcpy(op1,"                     ");
       strcpy(op2,"                     ");
       strcpy(op3,"                     ");
       strcpy(op4,"                     ");
       strcpy(correct,"   ");
       }

       void getdata()     //TO ENTER THE QUESTION AND OPTIONS IN THE FILE.
       {cout<<"\nEnter the question       :";
gets(ques);
cout<<"\nEnter the first option   :";
gets(op1);
cout<<"\nEnter the second option  :";
gets(op2);
cout<<"\nEnter the third option   :";
gets(op3);
cout<<"\nEnter the fourth option  :";
gets(op4);
cout<<"\nEnter correct option       :";
gets(correct);
       };
     void display()    //TO RETRIEVE THE QUESTIONS AND CORRESPONDING OPTIONS
      {puts(ques);     //FROM THE FILE.
       puts(op1);
       puts(op2);
       puts(op3);
       puts(op4);
       puts(correct);
      }
     };
void enterdata()       //TO ENTER THE DATA OF THE CONTESTANT.
     {cout<<"\n                   ";
      cout<<"Please Fill The Following Form:-\n\n\n";
      cout<<"NAME                       :";
      gets(name);
      cout<<"\nADDRESS                    :";
      gets(address);
      cout<<"\nDATE OF BIRTH (dd/mm/yyyy) :";
      gets(dob);
      cout<<"\nFATHER'S NAME              :";
      gets(fname);
      cout<<"\nAGE                        :";
      cin>>age;
      cout<<"\nTELEPHONE NUMBER           :";
      cin>>telno;
      eligibility();
      menu();
      };
void eligibility()  //FUNCTION DEFINATION TO CHECK ELIGIBILITY OF CONTESTANT BASED ON AGE.
    {if (age<18)
     {cout<<"\n\nYou are not eligible to play the game\n\n";
      cout<<"\nEnter any character to exit..";
      getch();
      exit(0);}
     else
       {
cout<<"\nYou are eligible to play the game\n\n";
cout<<"\nPress any key to continue to menu....\n\n";
getch();
       }
    };
void menu()   //TO DISPLAY A MENU.
    {clrscr();
     int a;
     cout<<"\n\n                          "
<<"Select the appropriate option\n\n"
<<"1. Play The Game\n\n"
<<"2. Read Rules And Regulations\n\n\n"
<<"Enter Your Choice (1 / 2) :";
     cin>>a;
     switch(a)
     {case 1 :break;
      case 2 :{rulnreg();break;}
      default:{cout<<"\nInvalid Choice Entered.....";
      cout<<"\n\nPress any key to return to menu";
      getch();
      menu();}
     }
    }
void rulnreg()    //TO DISPLAY RULES AND REGULATIONS.
     {cout<<"\n\n\n                             "
 <<"!!!!!!!!RULES AND REGULATIONS!!!!!!!!\n\n\n\n"
 <<"1.There are 5 questions ranging from Rs.10,000"
 <<"  to Rs.5,00,00,000.\n\n"
 <<"2.Each question will have four options with only"
 <<"  one correct option.\n\n"
 <<"3.Contestant can Quit the game by entering 'e'"
 <<"  or 'E' when answer is asked.\n\n"
 <<"4.Four lifelines are available during the game play.\n\n"
 <<"5.Contestant can't Quit the game while using lifelines.\n\n";
      cout<<"Press any key to return to menu...";
      getch();
      menu();
     }
void randomfn() //TO GENERATE AN ARRAY WITH RANDOM BUT NON REPEATED 5 NUMBERS FROM 0 TO 14.
     {int t;
      randomize();
      for(int i=0;i<=4;i++)
{label:
 t=random(15);
 for(int j=0;j<=4;j++)
    {if (a[j]==t)
{goto label;}
    }
 a[i]=t;

}
      }
void lifeline(char corr[1],int l) //FUNCTION FOR USE OF LIFELINES.
    {int ch;char answ[1];
    abc:

cout<<"\nWhich lifeline u want to use:-\n\n1.Expert advice.\n\n2.Double Dip.\n";
cout<<"\nEnter your choice(1/2):-";
cin>>ch;
if (ch==1)                //for expert advice.
  {if (count1==0)
   {count1++;            //to stop the multiple use of expert advice.
   cout<<"\nExpert Says That Correct Option Is "<< corr[0]<<"\n\n";
    cout<<"So , Enter Your final option(a/b/c/d):-";
    gets(answ);
    if((answ[0]==corr[0])||(answ[0]==tolower(corr[0])))
{ cout<<"\n\nThat's the right answer.Well played.\n\n" ;
 cout<<"Press Any Key To Proceed.....\n\n";
 getch();}
    else
      {cout<<"\nSorry,that was a wrong answer.You lost the game.\n\n";
cout<<"Congratulations You Are Leaving With "<<money[l+1]<<"\n\n";
cout<<"Press any key To Exit";
getch();
exit(0);}}
   else
{cout<<"\nThis Lifeline have been used once. Can't use this lifeline\n";
goto abc;}}

else
  {if(ch==2)                //for double dip.
     {if (count2==0)
      {count2++;            //to stop the multiple use of double dip.
for(int i=1;i<=2;i++)
 {cout<<"\nEnter your answer:-";
  cin>>answ;
  if((answ[0]==corr[0])||(answ[0]==tolower(corr[0])))
     {cout<<'\n'<<"\nThat's the right answer.Well played.Press Any Key To Proceed\n\n" ;
      getch();
      break;}
  else
    {cout<<"\n\nSorry,that was a wrong answer.\n\n";}}}
else
  {cout<<"\nThis Lifeline have been used once. Can't use this life line\n\n";
   goto abc;}}}}



 main()
 {clrscr();
  cout<<"\n\n\n     ----------!!!!!!! WELCOME TO KAUN BANEGA CROREPATI !!!!!!!----------\n\n";
  enterdata();
  fstream f;
  question m;
  char d;
  char ans[1];
  randomfn();            //to generate an array with random numbers.
  f.open("qna.dat",ios::in|ios::binary);      //read data from file "qna.dat".
  for (int i=0;i<=4;i++)
  {clrscr();
   cout<<"\n\n\n\n";
   cout.write(name,strlen(name));
   cout<<", here is your Question no "<<i+1<<" for Rs."<<money[i+1]<<" (Press Enter)\n\n";
   getch();
   f.seekg(0,ios::beg);
   f.seekg(a[i]*sizeof(m),ios::cur);
   f.read((char*)&m,sizeof(m));
   cout.write(m.ques,sizeof(m.ques));
   cout<<"\n\nPress any key for options.....\n\n";
   getch();
   cout.write(m.op1,sizeof(m.op1));
   cout.write(m.op2,sizeof(m.op2));
   cout<<"\n\n";
   cout.write(m.op3,sizeof(m.op3));
   cout.write(m.op4,sizeof(m.op4));
   cout<<"\n\n";
   cout<<"L or l->LIFELINE    ";
   cout<<"E or e->EXIT        ";
label:
   cout<<"\n\nEnter the correct option (a/b/c/d)   : ";
   gets(ans);
   if ((ans[0]=='e')||(ans[0]=='E'))        //to exit the game.
     {cout<<"\nAre you sure you want to Exit.....? (y/n) : ";
      cin>>d;
      if((d=='y')||(d=='Y'))
{cout<<"\n\nYou are leaving with Rs."<<money[i]<<".";
cout<<"\n\nPress any key to Exit......";
getch();
exit(0);
}}
   if ((ans[0]=='l')||(ans[0]=='L'))       //to use a lifeline.
      {if ((count1==0)||(count2==0))
 lifeline(m.correct,i);
      else
{cout<<"\nNo Lifeline Available\n\n";
goto label;  } }
    else

   {if ((ans[0]==m.correct[0]) || (toupper(ans[0])==m.correct[0]))
     {cout<<"\nThats the right Answer....";
      cout<<"\n\nCongratulations you have won Rs."<<money[i+1]<<".";
      cout<<"\n\nPress any key to proceed....\n\n";
      getch();
     }
   else
      {cout<<"\n\nThats the Wrong Answer...";
       cout<<"\n\nYou have lost the game...";
       cout<<"\n\nYou are leaving with Rs."<<money[i]<<".";
       cout<<"\n\nPress any key to Exit.....";
       getch();
       exit(0);
      }
   }
}
}













Friday, 14 February 2014

RESULT MANAGEMENT SYSTEM

 //A program by Lakshay


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
struct stud{
    int roll;
    char name[20],address[20],fname[20],grade;
    int m[5];
    int total;
    int perc;
    }student[5],child;

struct subj{
  char name[10];};
  int average=0;


  void names(stud student[5])
  {  cout<<"Enter The Name of 5 Students\n";
   for (int i=0;i<5;i++)
    {
    gets(student[i].name);
    cout<<endl;
    student[i].name[0]=toupper(student[i].name[0]);
    }

  }


 void address(stud student[5])
 { cout<<"Enter the Address of the Respective Students\n";
   for (int i=0;i<5;i++)
    { cout<<student[i].name<<endl;
      gets(student[i].address);
      cout<<endl;
    }
  }

 //for input of father's name
 void fname(stud student[5])
  {
   cout<<"Enter the Father's name of the following students -\n";
   for (int i=0;i<5;i++)
     {
       cout<<student[i].name<<endl;
       gets(student[i].fname);
       cout<<endl;
       student[i].fname[0]=toupper(student[i].fname[0]);
       for(int j=0;j!='\0';j++)
       if(student[i].fname[j]==' ')
       student[i].fname[j+1]=toupper(student[i].fname[j+1]);

     }
   }


 //for input of marks
 void marks(stud student[5],subj sub[5])
 { cout<<"Enter the Marks of the foll Student\n";
 for (int i=0;i<5;i++)
  {
    student[i].total=0;
    cout<<student[i].name<<"\n";
    for (int j=0;j<5;j++)
     {
       cout<<sub[j].name<<" = ";
       cin>>student[i].m[j];
      student[i].total+=student[i].m[j];

     }
     student[i].perc=student[i].total/5;
     average+=student[i].total;
     if(student[i].perc>=90)
       student[i].grade='A';
else if((student[i].perc<90)&&(student[i].perc>=75))
student[i].grade='B';
 else if((student[i].perc<75)&&(student[i].perc>=60))
   student[i].grade='C';
   else if((student[i].perc<60)&&(student[i].perc>=40))
     student[i].grade='D';
     else  student[i].grade='F';
   }
 }

//for showing the data
void show(stud student[5],subj sub[5])
 {
 for (int i=0;i<5;i++)
   {
    cout<<"the name of student....\n"<<student[i].name<<"\nAddress...."<<student[i].address<<"\nFather's name...\n"<<student[i].fname<<endl;
    for(int j=0;j<5;j++)
    cout<<sub[j].name<<"=="<<student[i].m[j]<<endl;
   }
 }

//for sorting students according to names
void sorting(stud student[5], stud child)
{
int a,b,k=0;
    for(int i=0;i<5;i++)
   {
    for(int j=i+1;j<5;j++)
    {
      k=0;
      _1:
      a=tolower(student[i].name[k]);
      b=tolower(student[j].name[k]);
      if(b<a)
      {
child=student[j];
student[j]=student[i];
student[i]=child;
      }
      if(b==a)
{
 k+=1;
 goto _1;
}
     }
  }

}
//for roll no.
void roll(stud student[5])
{
 for(int i=0;i<5;i++)
 student[i].roll=i+1;
 }
// for creating arrays
void creatn_arrays(stud student[5],subj sub[5],stud child)
 {
  names(student);
  address(student);
  fname(student);
  marks(student,sub);
  sorting(student,child);
  roll(student);
 }
 //for report card
 void reportcard(stud student[5],subj sub[5])
 { char a;int r;
   cout<<"NAME LIST\n(Roll No.---Name---)\n";
   for(int i=0;i<5;i++)
   {
   cout<<student[i].roll<<". "<<student[i].name<<endl;
   }
  _1:
  cout<<"Enter the roll no. of the student whose report card is to be seen...."<<endl;
  for(i=0;i<5;i++)
    {
     cout<<student[i].roll<<". "<<student[i].name<<endl;
    }
    cin>>r;
    cout<<"NAME - "<<student[r-1].name<<endl<<"ROLL NO.-"<<r<<endl<<"FATHER'S NAME - "<<student[r-1].fname<<"\nADDRESS - "<<student[r-1].address<<"\nMarks--\n";
    for(i=0;i<5;i++)
    cout<<sub[i].name<<"-- "<<student[r-1].m[i]<<endl;
    cout<<"Total marks(out of 500)= "<<student[r-1].total<<"\nPercentage = "<<student[r-1].perc<<"\nGRADE = "<<student[r-1].grade<<endl;
    cout<<"Do you want to see report card more? y/n\n";
    cin>>a;
    if(a=='y')
    goto _1;
    }
 //for merit list
 void merit_list(stud student[5])
 {
  cout<<"Merit List(--roll no.--name--total--average--)"<<endl;
  for(int i=0;i<5;i++)
  cout<<student[i].roll<<". "<<student[i].name<<"    "<<student[i].total<<"    "<<average/5<<endl;
 }

 //for grade card
 void grade_card(stud student[5])
 {
  cout<<"Grade Card(roll no.--name--Total--Grade--)"<<endl;
  for(int i=0;i<5;i++)
  cout<<student[i].roll<<". "<<student[i].name<<"    "<<student[i].total<<"    "<<student[i].grade<<endl;
 }


void main()
  {
  char a[5];
  int k=0;
  clrscr();
  subj sub[5]={{"Physics"},{"Chemistry"},{"Maths"},{"Computers"},{"English"}};
  creatn_arrays(student,sub,child);

  cout<<"Do you want to Disply the Data Entered ? y/n \n ";
  cin>>a[k];
  if (a[k++]=='y')
  show(student,sub);
  reportcard(student,sub);
  cout<<"Do you want to disply the Merit List ? y/n \n ";
  cin>>a[k];
  if (a[k++]=='y')
  merit_list(student);
  cout<<"Do you want to disply the Grade card ? y/n \n ";
  cin>>a[k];
  if (a[k++]=='y')
  grade_card(student);
  cout<<"Thanks for using this program :-) :-)\n A program Lakshay :-D\n";
  getch();
  }


        // HERE ARE SOME OUTPUT SCREENS







Thursday, 13 February 2014

HURDLE RACE ( BASIC TEMPLE RUN )

// A PROJECT BY VIKAS AGGARWAL AND AAKASH MITTAL 

#include<iostream.h>
#include<conio.h>
#include<time.h>
#include<graphics.h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>
#include<stdio.h>
main()
{ restart: clrscr(); textbackground(15);textcolor(4);
  cout<<"\n\t\t\t\t\tROAD OF THE DEAD\n\n\n"
      <<" #-YOUR CAR\n\n *-HURDLES\n\n"
      <<" COMMANDS:\n 1.j- move left\n\n 2.l- move right\n\n"
      <<" DIFFICULTY\n A.LEARNER\n B.EXPERT\n\n PRESS E To GO BACK TO MENU"
      <<"\n\n ENTER YOUR CHOICE:";
      char ch= getche();
    if((ch!='a')&&(ch!='A')&&(ch!='b')&&(ch!='B')&&(ch!='e')&&(ch!='E'))
goto restart;
    if((ch=='e')||(ch=='E'))
exit(0);
      char A[49][11]; int h=45; int p=13;  int i,j,k,speed,score=0;
      for(i=3; i>0; i--)
       { delay(1000); clrscr();
cout<<"\n\n\n\n\n\n\n\t\t\t\t\t\t"<< i; delay(1000); clrscr();
       }
  for (int t=1; t<3; t++)
    {
       for(int v=1;v<=49;v++)
      {
if((ch=='a')||(ch=='A'))      // learner path
       {
 for(i=0;i<49; i++)
   for(j=0; j<11; j++)
    { A[i][j]=' ';
      if((j==0)||(j==10))
      A[i][j]='*';
    }
 for(i=3;i<49; i=i+13)
   { A[i][2]='*';
     A[i][5]='*';
     A[i][8]='*';
   }
 for(i=6;i<49; i=i+10)
   { A[i][4]='*';
     A[i][6]='*';
     A[i][9]='*';
   }
for(i=8;i<49; i=i+13)
  { A[i][1]='*';
    A[i][3]='*';
    A[i][7]='*';
  }
for(i=0;i<49;i++)
 {
   for(j=0; j<11; j++)
    {
      k=j+40; gotoxy(k,(i+1));
      cout<<A[i][j];
    }
   cout<<'\n';
 }
       speed=300;
       speed=speed-(2*v);
      }
    else
     {                                  //expert path
       for(i=0;i<49; i++)
for(j=0; j<11; j++)
  { A[i][j]=' ';
    if((j==0)||(j==10))
    A[i][j]='*';
  }
       for(i=3;i<49; i=i+7)
  { A[i][2]='*';
    A[i][5]='*';
    A[i][8]='*';
  }
       for(i=6;i<49; i=i+8)
  { A[i][4]='*';
    A[i][6]='*';
    A[i][9]='*';
  }
       for(i=8;i<49; i=i+7)
 { A[i][1]='*';
   A[i][3]='*';
   A[i][7]='*';
 }
       for(i=0;i<49;i++)
       {
for(j=0; j<11; j++)
{
  k=j+40; gotoxy(k,(i+1));
  cout<<A[i][j];
}
cout<<'\n';
       }
     speed=250;
     speed=speed-(2*v);
   }
   if (kbhit())
     {  char cmnd=getch() ;
if(cmnd=='l')
 h=h+1 ;
if(cmnd=='j')
  h=h-1 ;
     }
   gotoxy(h,v);
   score=score+(3*v);
   cout<<"#";
   char c=A[v-1][h-40] ;
    if(c=='*')
      goto gameover;
//  speed=speed-(2*v);
    delay(speed);
   }
 }
 gameover: clrscr();
 cout<<"\n\n\n\n\t\t\t\tGAME OVER"
     <<"\n\n\t\t\t\tYOUR SCORE IS "
     <<score;
 getch();
 goto restart;
}



      // HERE ARE SOME OUT OUTPUT SCREENS






SHAKE SQUARE

// A PROJECT BY GINNI TANEJA AND AANCHAL MAHESHWARI


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<dos.h>
#include<string.h>
#include<graphics.h>
// delay function delays the output of next command
 void hard ()  // to print stars and rows
 {
  char position[] = {'A', 'B', 'C', 'D', 'E'} ;


  gotoxy (43, 3);
  cout<<'F'<<'\n';
  for (int i=4, j=0, o=1, p=0; i<=32, j<5; i+=4, j++, o++, p++)
  {
   for (int k=43, m=0; k<=80, m<5; k+=8, m++)
   {
    gotoxy (k, i);
    cout<<'*'<<':';
   }
   gotoxy (k-45, i);
   cout<<position[p]<<'-';
   cout<<'\n';
  }
 }



 void menu ()  // to print the clues
 {
  cout<<"______________________________"<<'\n'<<'\n'<<
  "           ACROSS"<<'\n'<<'\n'<<"A. The highest possible square."<<'\n'<<
  "B. The lowest possible square."<<'\n'
  <<"C. The first three digits are"<<'\n'<<"   cube of prime number and"
  <<'\n'<<"   last two digits are square"<<'\n'<<"   of the same."<<
  '\n'<<"D. The highest possible cube."<<'\n'
  <<"E. Cube of a prime number."<<'\n'<<'\n'<<
"________________________________"<<'\n'<<'\n'<<
  "           DOWN"<<'\n'<<'\n'<<"F. The highest possible cube."<<'\n'
  <<"________________________________"<<'\n'<<'\n'<<
  "           HOW TO PLAY"<<'\n'<<'\n'<<"1. Enter yor desired row i.e."<<'\n'<<
  "   'A', 'B', 'C', 'D' or 'E' for"<<'\n'<<"   Across and 'F' for down."<<'\n'<<
  "2. Enter your number."<<'\n'<<
  "3. If you want to quit,"<<'\n'<<"   enter 'Q', and if you"<<'\n'<<
  "   want to submit, enter 'S'.";  // instructions to play the game
 }


 int Process ()
 {
  New:
  char ch, choice, result, position[] = {'A', 'B', 'C', 'D', 'E'}, position2[] = {'a', 'b', 'c', 'd', 'e'};
  long no[6]={0,0,0,0,0,0}, b, c, d, e, f, ans[6]={99856, 71289, 34349, 35937, 68921, 97336};
  int y;

  Start:
  gotoxy(37, 22);
  cout<<"->"<<"Enter position alphabet"<<":  "; // for the user to play
  gotoxy(37, 23);
  cout<<"                                   ";
  gotoxy(63, 22);
  ch=getche();
  getch();

  if ((ch!='Q')&&(ch!='q')&&(ch!='A')&&(ch!='a')&&(ch!='B')&&(ch!='b')
&&(ch!='C')&&(ch!='c')&&(ch!='D')&&(ch!='d')&&(ch!='E')&&(ch!='e')&&(ch!='F')&&(ch!='f')&&(ch!='S')&&(ch!='s'))
goto Start;    // entering alphabet again

  if ((ch=='Q')||(ch=='q')) // game ends
  exit (0);

  if ((ch=='S')||(ch=='s')) // answers are submitted
  {
   clrscr();
   for (y=0, result='Y'; y<5; y++)   // checkings the answers
   {
if (no[y]!=ans[y])     // comparing the submitted answers from the original answers
result='N';
   }
   gotoxy (30, 6);
   if (result=='Y')
   {
cout<<"You Win";
delay(3000);
exit (0);
   }
   else
   cout<<"You Lose";
   delay(1000);
   gotoxy (20, 9);
   cout<<"Press 'R' to see the solution ";     // solutions will be shown
   gotoxy (20, 10);
   cout<<"or 'E' to exit : ";         // program will end
   Do:
   cin>>choice;
   if ((choice=='R')||(choice=='r'))   //checking the choice entered
  {
   gotoxy (1, 13);     // printing solution
   cout<<"A. The highest possible square = 99856"<<'\n'<<
  "B. The lowest possible square = 71289"<<'\n'
  <<"C. The first three digits are cube of prime number and the last two digits are square of the same = 34349"<<
  '\n'<<"D. The highest possible cube = 35937"<<'\n'
  <<"E. Cube of a prime number = 68921"<<'\n'<<"F. The highest possible cube = 97336";
   goto Do;   // choice is to be entered
   }
   if ((choice=='E')||(choice=='e'))
   exit (0);
   else
   goto Do;// choice is to be entered


  }

  again:       // for entering numbers
  gotoxy(37, 23);
  cout<<"->"<<"Enter your number      "<<":                ";



  if ((ch=='F')||(ch=='f'))  // entering the number in F (down)
  {
   gotoxy(63, 23);
   cin>>no[5];
   long K= no[5];
   if(K>99999)
   goto again;       // the no. is to be entered again

else
 b=no[5];     // entered no. is saved in variable b
   for (int i=46, j=4, k=0, number=10000; j<=32, k<5; j+=4, k++, number/=10)
   {
int a=b/number;     // to enter the 5digit no. down the grid
b%=number;
gotoxy (i,j);
cout<<a<<"  ";
   }
   e=no[5];
  for (int n=0, num=10000; n<5; n++, num/=10)
   {
c = e / num;
e = e % num;
d = no[n]%10000;
no[n] = (c*10000) + d;          // number is saved in the array- no
   }
  }

  else
  for (int i=38, j=4, m=0, n=0; i<=80, j<=32, m<5, n<5; j+=4, m++, n++)
  {
   if ((ch==position[n])||(ch==position2[n]))         // position of entered alphabet is checked
   {

gotoxy(63, 23);
cin>>no[n];
long K=no[n];
if(K>99999)
goto again;  // no. is to be entered again if it is >99999
b=no[n];       //no. is saved in variable b
for (int k=0, l=i+8, number=10000; k<5; l+=8, k++, number/=10)
{
int a=b/number;
b%=number;
gotoxy (l,j);
cout<<a<<"  ";    // each digit of the no.is printed in each column of specified position
}
   }
  }

  goto Start;     // the process is started again
 }

 void screen1()
 {
  clrscr ();          //to print the output of first screen
  char CH;
  delay(1000);
  gotoxy (30, 4);
cout<<"MATHEMATICAL PUZZLE";
  delay(2500);
  gotoxy (21, 7);
  cout<<"So you think you are a Maths Wizard?!?";
  delay(2500);
  gotoxy (25, 9);
  cout<<"Let us see";
  delay(600);
  cout<<'.';
  delay(600);
  cout<<'.';
  delay(600);
  cout<<'.';
  delay(1500);
  cout<<"here's the test!";
  delay(2500);
  gotoxy (22, 11);
  cout<<"Press 'S' to start or 'E' to exit : ";
  dobara:
  gotoxy (58, 11);
  cin>>CH;            // choice is to be entered
  if ((CH=='E')||(CH=='e'))
  exit (0);
  if ((CH!='S')&&(CH!='s'))
  goto dobara;
  clrscr ();
 }

 void screen2()      // for printing the output of screen2
 {
  delay(1000);
  gotoxy (22, 5);
  cout<<"           HOW TO PLAY";          // instructions to play the game
  delay(2000);
  gotoxy (15, 7);
  cout<<"1. Enter yor desired row i.e.";
  gotoxy (15, 8);
  cout<<"   'A', 'B', 'C', 'D' or 'E' for Across and 'F' for down.";
  delay(4000);
  gotoxy (15, 10);
  cout<<"2. Enter your number.";
  delay(3000);
  gotoxy (15, 12);
  cout<<"3. If you want to quit, enter 'Q'";
  gotoxy (15, 13);
  cout<<"  and if you want to submit, enter 'S'.";
  delay(6000);
  clrscr ();
 }

 void screen3 ()                // for printing the output of screen3
 {
  for (int i=0; i<3; i++)
  {
   gotoxy (28, 14);
   cout<<"Loading";
   gotoxy (35, 14);
   delay(800);
   gotoxy (37, 14);
   delay(800);
   gotoxy (39, 14);
   delay(800);
   clrscr ();
  }
 }

 main ()           // the execution begins from here
 {
  clrscr ();
  screen1 ();
  screen2 ();
  screen3 ();
  menu ();
  hard ();
  Process ();

  getch ();
 }



// HERE ARE THE OUTPUT SCREENS 
















Wednesday, 12 February 2014

Bank Management System

//A PROJECT BY LAKSHAY NAGPAL
//Creating and Modifing an Account in the bank


#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<fstream.h>
#include<stdio.h> //rename() , remove()
#include<string.h>

class AVR
{
long accno;    //account number
char name[40];    //customer name
char add[50]; //address of customer
float amount; //total amount in account
public:
void accept();
void display();
void search();
void modify();
void del();
void readfile();
void writefile();
}S;
fstream f;
void AVR::accept()
{
cout<<"\nEnter The Name Of Customer :\n\n\n\n";
gets(name);
cout<<"\nEnter The Address Of Customer :\n\n\n\n";
gets(add);
cout<<"\nEnter The Account Number :\n\n\n\n";
cin>>accno;
cout<<"\nEnter Total Amount In Customer's Account :\n\n\n\n";
cin>>amount;
getch();
}
void AVR::display()
{
cout<<"\n\t\t\tThe Name Of The Customer Is :\n\n\n\n\t\t\t";
puts(name);
cout<<"\n\t\t\tThe Address Of The Customer Is :\n\n\n\n\t\t\t";
puts(add);
cout<<"\n\t\t\tCustomers Account Number Is :\n\n\n\n\t\t\t";
cout<<accno;
cout<<"\n\t\t\tPresent Ammount In Customer's Account Is :\n\n\n\n\t\t\t";
cout<<amount;
getch();
}
void AVR::writefile()
{
f.open("AVR.DAT",ios::app|ios::binary);
accept();
f.write((char*)&S,sizeof(S));
f.close();
}
void AVR::readfile()
{
f.open("AVR.DAT",ios::in|ios::binary);
if(!f)
{
cout<<"****EMPTY FILE****";
getch();
return;
}
while(f.read((char*)&S,sizeof(S)))
{
display();
getch();
clrscr();
}
f.close();
}
void AVR::search()
{
long taccno;
int flag=0;
cout<<"Enter The Account Number To Be Searched :\n";
cin>>taccno;
f.open("AVR.DAT",ios::in|ios::binary);
while(!f.eof())
{
f.read((char*)&S,sizeof(S));
if(f.eof())
break;
if(S.accno==taccno)
{
S.display();
getch();
flag=1;
}
}
if(flag==0)
{
cout<<"The Account Number Does Not Exist\n";
getch();
}
f.close();
}

void AVR::del()
{
long taccno;
int check=0;
fstream f1;
cout<<"Enter The Account Number To Close The Account :\n";
cin>>taccno;
f.open("AVR.DAT",ios::in|ios::binary);
f1.open("RAV.DAT",ios::out|ios::binary);
f.seekg(0);
while(!f.eof())
{
f.read((char*)&S,sizeof(S));
if(taccno!=accno)
{
if(!f.eof())
f1.write((char*)&S,sizeof(S));
}
else if(taccno==accno)
check=1;
}
f.close();
f1.close();
remove("AVR.DAT");
rename("RAV.DAT","AVR.DAT");
if(check==0)
cout<<"\t\t\t***Account Number Not Found***\n";
else
cout<<"\n\n\n\n\t\t  ****Account Closed Successfully****\n";
getch();
}
void AVR::modify()
{
long taccno;
int tamount;
float withdraw,deposit;
char tadd[55];
int choice,t=0,flag=0,n=0;
cout<<"\n\n\n\nEnter The Customer's Account Number :\n";
cin>>taccno;
f.open("AVR.DAT",ios::in|ios::out|ios::binary);
while(!f.eof())
{
n++;
f.read((char*)&S,sizeof(S));
if(f.eof())
break;
if(S.accno==taccno)
{
flag=1;
S.display();
cout<<"\n\n\n1.Modify Customer's Address.";
cout<<"\n\n\n2.Enter Amount Withdrawl.";
cout<<"\n\n\n3.Enter Amount Deposited.";
cout<<"\n\n\n4.Exit";
cout<<"\n\n\nEnter your choice :";
cin>>choice;
switch(choice)
{
case 1:t=(n-1)*sizeof(S);
cout<<"\n\nEnter Customer's New Address :\n";
gets(tadd);
strcpy(add,tadd);
f.seekp(t,ios::beg);
f.write((char*)&S,sizeof(S));
cout<<"\n\n\t\t\t\tAddress Is Modified";
getch();
break;
case 2:t=(n-1)*sizeof(S);
cout<<"\n\nEnter The Withdrawl Amount :\n";
cin>>withdraw;
if(withdraw>0)
{
amount=amount-withdraw;
f.seekp(t,ios::beg);
f.write((char*)&S,sizeof(S));
cout<<"\n\n\n\t\t\t\tAmount Modified";
getch();
}
break;
case 3:t=(n-1)*sizeof(S);
cout<<"\n\n\nEnter The Deposited Amount :\n";
cin>>deposit;
if(deposit>0)
{
amount=amount+deposit;
f.seekp(t,ios::beg);
f.write((char*)&S,sizeof(S));
cout<<"\n\n\t\t\t\t\tAmount Modified";
getch();
}
break;
case 4:return;
default:cout<<"\n Wrong Choice";
}
}
}
if(flag==0)
{
cout<<"\n****Account Number Not Found****";
getch();
}
f.close();
}
void main()
{
clrscr();
int ch=1;
cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t____________________________\n\n";
cout<<"\t\t\tWELCOME TO AVR BANK OF INDIA";
cout<<"\n\t\t\t____________________________";
cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\t  PRESS ENTER TO CONTINUE";
getch();
while(ch!=6)
{
clrscr();
cout<<"\n\n\t\t\t\t   MAIN MENU\n";
cout<<"\n\n\n\n\n\n\n\t\t\t1.Enter Records";
cout<<"\n\n\n\n\t\t\t2.Display Records";
cout<<"\n\n\n\n\t\t\t3.Search Records";
cout<<"\n\n\n\n\t\t\t4.Modify Account Records";
cout<<"\n\n\n\n\t\t\t5.Close Account";
cout<<"\n\n\n\n\t\t\t6.EXIT";
cout<<"\n\n\n\n\n\n\nEnter Your Choice :\n";
cin>>ch;
switch(ch)
{
case 1:clrscr();
cout<<"\n\n\t\t\t\t***ADD RECORD***\n\n\n\n";
S.writefile();
break;
case 2:clrscr();
cout<<"\n\n\t\t\t\t***DISPLAY RECORD***\n\n\n\n\n";
S.readfile();
break;
case 3:clrscr();
cout<<"\n\n\t\t\t\t***SEARCH RECORD***\n\n\n\n";
S.search();
break;
case 4:clrscr();
cout<<"\n\n\t\t\t\t***MODIFY RECORD***\n\n\n\n";
S.modify();
break;
case 5:clrscr();
cout<<"\n\n\t\t\t\t***DELETE ACCOUNT***\n\n\n\n";
S.del();
break;
case 6:return;
default:cout<<"\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t**WRONG CHOICE**";
}
}
}