You are on page 1of 98

#include<iostream.

h>
#include<conio.h>
#include<process.h>
int main()
{clrscr();
char ch;
float l,b,area,perimeter;
cout<<"\n rectangle menu";
cout<<"\n 1.Area";
cout<<"\n 2.Perimeter";
cout<<"\n 3.exit"<<"\n";
cout<<"enter your choice";
do
{cin>>ch;
if((ch=='1')||(ch=='2'))
{
cout<<"enter the value of length and breadth";
cin>>l>>b;}
switch(ch)
{ case'1':area=l*b;
cout<<"area"<<area;

break;
case'2':perimeter=2*(l+b);
cout<<"perimeter"<<perimeter;
break;
default:cout<<"wrong menu";
cout<<"\n want to continue(y/n)?";
cin>>ch;}}
while((ch=='y')||(ch=='y'));
return 0;
}

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

void main()
{clrscr();
int n;
cout<<"enter the employee number";
cin>>n;
{if((n>=26)&&(n<=35))
cout<<"the age group b/w 26-35";
else
cout<<"not in range";}
{if((n>=36)&&(n<=45))
cout<<"the age group b/w 36-45";
else
cout<<"not in range";}
{if((n>=46)&&(n<=55))
cout<<"the age group b/w 46-55";
else
cout<<"not in range"; }
getch();}

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

void func(int *ptr,int *sum)


{for(int i=0;i<5;i++)
*sum=+((*ptr++)*(*ptr++));
cout<<"The sum is::"<<*sum;

}
void main()
{clrscr();
int a[5];
int sum;
//int *ptr=&a[0];
//int *sum=&sum;
cout<<"enter the element::\n";
for(int i=0;i<5;i++)
cin>>a[i];
func(a,sum)
getch();
}

#include<iostream.h>
#include<conio.h>
void main()
{clrscr();

int pnum[5]={1,2,3,4,5};
int sum;
int *ptr=&pnum[0];
int *psum=&sum;
for(int i=0;i<5;i++)
*psum=(*psum)+(*ptr);
ptr=ptr+1;
cout<<"Sum is::"<<*psum;
getch();
}

#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
void oper()

{cout<<"\nOperator:\n";
cout<<"It is defined as the operations are representd by the operators and the
objects are referred to as operand\n\n";

}
void arith()
{ int ch;
cout<<"Arithmetic operators\n";
delay(1200);
cout<<"It provides operations for five basic arithmetic
calculations:addition,subtraction,multiplication,division and remainder
respectively.\n";
cout<<"There are different types of operators\n";
delay(1200);
cout<<"1.Unary Operators\n2.Binary operators\n3.Ternary operators \n4.logical
operators\n5.Type conversion\n6.exit\n";
cout<<"enter your choice\n";
cin>>ch;
switch(ch)
{case 1:cout<<"unary Operators\n";
cout<<"It act upon one operands\n";
cout<<"Example implementing all unary operators\n";
int n,i=1,sum=0;
cout<<"enter the value of n:";
cin>>n;
cout<<"n first"<<n<<"natural numbers are :nn";
do
{
cout<<i;
sum=sum+i;

i++;
}
while(i<=n);
cout<<"nn sum="<<sum;
break;
case 2:cout<<"Binary operators\n";
cout<<"It act on two operand \n";
cout<<"Exampal implementing all binary Operators\n";
char choi;
float l,b,area,perimeter;
cout<<"\n rectangle menu";
cout<<"\n 1.Area";
cout<<"\n 2.Perimeter";
cout<<"\n 3.exit"<<"\n";
cout<<"enter your choice";
do
{cin>>choi;
if((choi=='1')||(choi=='2'))
{
cout<<"enter the value of length and breadth";
cin>>l>>b;}
switch(choi)
{ case'1':area=l*b;
cout<<"area"<<area;
break;
case'2':perimeter=2*(l+b);
cout<<"perimeter"<<perimeter;
break;

default:cout<<"wrong menu";
cout<<"\n want to continue(y/n)?";
cin>>choi;}}
while((choi=='y')||(choi=='y'));
break;
case 3:cout<<"Ternary operators\n";
cout<<"It act upon three operands\n";

break;
case 4:cout<<"Logical operators \n";
cout<<"These are ||(logical Or),&&(Logical AND) and! (logical NOT)\n";
cout<<"Example implementing logical operators\n";
int rem;
cout<<"enter the number";
cin>>n;
while(n!=0)
{
rem=n%10;
sum+=rem;
n/=10;
}
cout<<"the sum of the digits of the number is "<<sum;
break;
case 5:char chi;
cout<<"Type conversion\n";
cout<<"It is a process of converting one predefined type into another\n";
cout<<"There are two types of conversion \n";
cout<<"a.Implicit type conversion\nb.Explicit type conversion\n";

cin>>chi ;
switch(chi)
{case 'a':cout<<"Implicit type conversion\n";
cout<<"It is a conversion performed by the compiler without programmer's
intervention.\n";
break;
case 'b':cout<<"Explicit type conversion\n";
cout<<"It is user defined that forces an expression to be of specific type\n";
break;
default :cout<<"wrong choice\n";
}
}
}
void main()
{clrscr();
cout<<"Chapter 8:Operators and expression in c++\n";
oper();
arith();
getch();
}

#include<iostream.h>
#include<conio.h>
#include<dos.h>
void main()
{clrscr();
cout<<"OBJECT ORIENTED PROGRAMMING CONCEPTS \n";

cout<<"Object Oriented Programming follows bottom up approach in program


design and emphasizes on safety and security of data....\n";
cout<<"FEATURES OF OBJECT ORIENTED PROGRAMMING:.....\n";
cout<<"1.Inheritance: \n ";delay(1000);
cout<<" Inheritance is the process of forming a new class from an existing class
or base class. The base class is also known as parent class or super class.\n";
cout<<" Derived class is also known as a child class or sub class. Inheritance
helps in reusability of code , thus reducing the overall size of the program\n";
cout<<"2.Data Abstraction:....\n";delay(1000);
cout<<" It refers to the act of representing essential features without including
the background details .Example : For driving , only accelerator, clutch and brake
controls need to be learnt rather than working of engine and other details.\n";
cout<<"3.Data Encapsulation: ......\n";delay(1000);
cout<<" It means wrapping up data and associated functions into one single
unit called class..\n";
delay(1678);
cout<<" A class groups its members into three sections :public, private and
protected, where private and protected members remain hidden from outside
world and thereby helps in implementing data hiding.\n";
cout<<"4.Modularity : ....\n";delay(2001);

cout<<" The act of partitioning a complex program into simpler fragments


called modules is called as modularity.\n";
cout<<" It reduces the complexity to some degree and It creates a number of
well defined boundaries within the program .\n";

cout<<"The major components of Object Oriented Programming are


.....\n";delay(1000);
cout<<" Classes & Objects A Class is a group of similar objects . Objects share
two characteristics: They all have state and behavior. For example : Dogs have
state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail).
Bicycles also have state (current gear, current pedal cadence, current speed) and

behavior (changing gear, applying brakes). Identifying the state and behavior for
realworld objects is a great way to begin thinking in terms of object-oriented
programming. These real-world observations all translate into the world of
object-oriented programming. Software objects are conceptually similar to realworld objects: they too consist of state and related behavior. An object stores its
state in fields (variables in some programming languages) and exposes its
behavior through functions\n";
getch();
}

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
void func(int ch)
{cout<<"There are different types of tokens in c++ these are:\n";

cout<<"1:Keywords\n"<<"2:identifires\n"<<"3:Literals\n"<<"4:Punctuators\n"<
<"5:Operators\n";
cout<<"Enter your choice\t\n";
cin>>ch;
switch(ch)
{case 1:int y;
cout<<"keywords\n";
cout<<"keywords are the words that convey a special meaning to the
language compiler.These are reserved for special purpose and must not be use
as normal identifier name.";
break;
case 2:cout<<"identifire\n";
cout<<"Identifire are fundamental building blocks of a program and are used as
the general terminology for the names";
cout<<"\t given to different parts of the program
viz.variables,objects,classes,functions,etc";
break;
case 3:char ch;
cout<<"Literals\n";
cout<<"Literals are data items that never change their value during a program
run\n";
cout<<"literals are of various types\n";
cout<<"a.Bool literals\n"<<"b.Interger constant\n"<<"c.character
constant\n"<<"d.Floating constant\n"<<"e.String literals\n";
cout<<"Enter your choice\t";
cin>>ch;
switch(ch)
{case 'a':cout<<"Bool literals\n";
cout<<"The bool literals in c++ is used to represent one of the two
boolean values i.e true or false.\n";
break;

case 'b':cout<<"Integer constant\n";


cout<<"It is whole numbers without any fractional part.\n";
break;
case 'c':cout<<"Character constants\n";
cout<<"It is one character enclose in single quotes,as in''.\n";
break;
case 'd':cout<<"Floating constants\n";
cout<<"These are numbers having fractional parts.\n";
break;
case 'e':cout<<"String literals\n";
cout<<"Multiple character constantts are treated as string literals\n";
break;
}
break;
case '4':cout<<"Punctuators\n";
cout<<"Let you give more info about punctuators\n";
cout<<"Brackets[]\n";
cout<<"parentheses()\n";
break;
case '5':cout<<"operators";
break;
default :cout<<"you have entered wrong choice";
}}
void main()
{
textcolor(GREEN);
clrscr();
delay(100);

textmode(C80);
cout<<"\nW-\aE-\aL-\aC-\aO-\aM-\aE-\a T\a-O\a C\a-H\a-A\a-P\a-T\a-E\a-R\a=
6"<<"\n\t\t\t"<<"GETTING "<<"\n\t\t\t\t"<<"STARTED"<<"\n\t\t\t\t\t"<<" WITH
"<<"\n\t\t\t\t"<<"C++"<<"\n";
char ch;
delay(900);
cout<<char(6)<<"\n\t"<<char(3)<<"\n";
func(ch);
getch();
}

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

#include <ctype.h>
#include <conio.h>
#include <dos.h>

class DRAW
{
public :
void LINE_HOR(int, int, int, char) ;
void LINE_VER(int, int, int, char) ;
void BOX(int,int,int,int,char) ;
};

class TICKET
{
public :
void ADDITION(void) ;
void ENQUIRY(void) ;
char *FLIGHTNO(int) ;
private :
void ADD_RECORD(char[10], char[15], char[15], int, int) ;
protected :
char fltno[10], from[15], to[15] ;
int ecofair, exefair ;
};

class PASSANGER

{
public :
void ADD_RECORD(int, int, char[26], char[36], int, char, char) ;
void DELETE_TICKET(int) ;
int DELETE_FLIGHT(int) ;
void LIST(void) ;
int LAST_TICKETNO(void) ;
int SEATS(int) ;
int FOUND(int) ;
char *NAME(int) ;
protected :
char Class, name[26], address[36], sex ;
int slno, age, ticketno ;
};

class RESERVE : public TICKET, public PASSANGER


{
public :
void RESERVATION(void) ;
void CANCELLATION(void) ;
void DISPLAY_TICKET(void) ;
void DELETE_ALL(void) ;
};

void DRAW :: LINE_HOR(int column1, int column2, int row, char c)


{
for ( column1; column1<=column2; column1++ )

{
gotoxy(column1,row) ;
cout <<c ;
}
}
void DRAW :: LINE_VER(int row1, int row2, int column, char c)
{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}

void DRAW :: BOX(int column1, int row1, int column2, int row2, char c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}

else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout <<c1 ;
gotoxy(column2,row1) ;
cout <<c2 ;
gotoxy(column1,row2) ;
cout <<c3 ;
gotoxy(column2,row2) ;
cout <<c4 ;
column1++ ;
column2-- ;
LINE_HOR(column1,column2,row1,l1) ;
LINE_HOR(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
LINE_VER(row1,row2,column1,l2) ;
LINE_VER(row1,row2,column2,l2) ;
}

void TICKET :: ADD_RECORD(char t_fltno[10], char t_from[15], char t_to[15], int


t_ecofair, int t_exefair)
{
fstream file ;
file.open("TICKET.DAT", ios::app) ;
strcpy(fltno,t_fltno) ;
strcpy(from,t_from) ;
strcpy(to,t_to) ;
ecofair = t_ecofair ;
exefair = t_exefair ;
file.write((char *) this, sizeof(TICKET)) ;
file.close() ;
}
char *TICKET :: FLIGHTNO(int sno)
{
fstream file ;
file.open("TICKET.DAT", ios::in) ;
int count=1 ;
while (file.read((char *) this, sizeof(TICKET)))
{
if (sno == count)
break ;
count++ ;
}
file.close() ;
return fltno ;
}

void TICKET :: ADDITION(void)


{
fstream file ;
file.open("TICKET.DAT", ios::in) ;
if (!file.fail())
return ;
file.close() ;
ADD_RECORD("KL146","DELHI","MUMBAI",1500,1700) ;
ADD_RECORD("KL146","MUMBAI","DELHI",1500,1700) ;
ADD_RECORD("KL156","DELHI","CALCUTTA",1700,1900) ;
ADD_RECORD("KL156","CALCUTTA","DELHI",1700,1900) ;
ADD_RECORD("KL166","DELHI","MADRAS",2100,2300) ;
ADD_RECORD("KL166","MADRAS","DELHI",2100,2300) ;
ADD_RECORD("KL176","MUMBAI","CALCUTTA",1900,2100) ;
ADD_RECORD("KL176","CALCUTTA","MUMBAI",1900,2100) ;
ADD_RECORD("KL186","MUMBAI","MADRAS",1800,2000) ;
ADD_RECORD("KL186","MADRAS","MUMBAI",1800,2000) ;
ADD_RECORD("KL196","CALCUTTA","MADRAS",1600,1800) ;
ADD_RECORD("KL196","MADRAS","CALCUTTA",1600,1800) ;
}
void TICKET :: ENQUIRY(void)
{
clrscr() ;
fstream file ;
file.open("TICKET.DAT", ios::in) ;
DRAW d ;
d.BOX(1,2,80,24,218) ;
d.LINE_HOR(2,79,4,196) ;

d.LINE_HOR(2,79,6,196) ;
d.LINE_HOR(2,79,22,196) ;
textcolor(LIGHTGRAY+BLINK) ;
gotoxy(30,3) ;
cprintf("LIST OF THE FLIGHTS") ;
textcolor(LIGHTGRAY) ;
textcolor(BLACK) ; textbackground(WHITE) ;
for (int i=2; i<=79; i++)
{
gotoxy(i,5) ;
cprintf(" ") ;
}
gotoxy(2,5) ;
cprintf(" Sno. FLIGHT NO.
FAIR") ;

FROM

TO

textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int row=7, sno=1 ;
while (file.read((char *) this, sizeof(TICKET)))
{
gotoxy(4,row) ;
cout <<sno ;
gotoxy(9,row) ;
cout <<fltno ;
gotoxy(20,row) ;
cout <<from ;
gotoxy(34,row) ;
cout <<to ;
gotoxy(52,row) ;
cout <<ecofair ;

ECONOMIC FAIR EXECUTIVE

gotoxy(67,row) ;
cout <<exefair ;
row++ ;
sno++ ;
}
file.close() ;
}
void RESERVE :: RESERVATION(void)
{
clrscr() ;
ENQUIRY() ;
char t1[5], pclass, pname[26], paddress[36], psex, pfltno[10] ;
int t2, valid, page, tno, sno ;
PASSANGER p ;
tno = p.LAST_TICKETNO() + 1 ;
do
{
valid = 1 ;
gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"PRESS <ENTER> TO EXIT" ;
gotoxy(3,20) ;
cout <<"

";

gotoxy(3,20) ;
cout <<"Enter Sno. of the FLIGHT : " ;
gets(t1) ;
t2 = atoi(t1) ;

sno = t2 ;
if (strlen(t1) == 0)
return ;
if (sno < 1 || sno > 12)
{
valid = 0 ;
gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
int i=1 ;
fstream file ;
file.open("TICKET.DAT", ios::in) ;
while (file.read((char *) this, sizeof(TICKET)))
{
if (sno == i)
break ;
i++ ;
}
file.close() ;
strcpy(pfltno,fltno) ;
if (p.SEATS(sno) >= 250)
{
gotoxy(5,21) ;
cout <<"\7Sorry! Seats are not available." ;

getch() ;
return ;
}
gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"E=ECONOMIC, X=EXECUTIVE or PRESS <ENTER> TO EXIT" ;
do
{
gotoxy(3,21) ;
cout <<"

";

gotoxy(3,21) ;
cout <<"By which Class you want to travel : " ;
pclass = getche() ;
pclass = toupper(pclass) ;
if (pclass == 13)
return ;
} while (pclass != 'E' && pclass != 'X') ;
clrscr() ;
gotoxy(72,3) ;
cout <<"<0>=EXIT" ;
gotoxy(34,2) ;
cout <<"RESERVATION" ;
gotoxy(5,5) ;
cout <<"NAME

:";

gotoxy(5,6) ;
cout <<"ADDRESS : " ;
gotoxy(5,7) ;

cout <<"SEX M/F : " ;


gotoxy(5,8) ;
cout <<"AGE

:";

do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NAME OF THE PASSANGER" ;
gotoxy(15,5) ; clreol() ;
gets(pname) ;
if (pname[0] == '0')
return ;
if (strlen(pname) < 1 || strlen(pname) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter Correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER ADDRESS OF THE PASSANGER" ;
gotoxy(15,6) ; clreol() ;
gets(paddress) ;
if (paddress[0] == '0')

return ;
if (strlen(paddress) < 1 || strlen(paddress) > 35)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter Correctly (Range: 1..35)" ;
getch() ;
}
} while (!valid) ;
do
{
gotoxy(5,25) ; clreol() ;
cout <<"ENTER SEX OF THE PASSANGER" ;
gotoxy(15,7) ; clreol() ;
psex = getche() ;
psex = toupper(psex) ;
if (psex == '0')
return ;
} while (psex != 'M' && psex != 'F') ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER AGE OF THE PASSANGER" ;
gotoxy(15,8) ; clreol() ;
gets(t1) ;
t2 = atoi(t1) ;
page = t2 ;

if (t1[0] == '0')
return ;
if (page < 1 || page > 100)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
DRAW d ;
d.BOX(15,5,66,21,'*') ;
d.LINE_HOR(16,65,7,'*') ;
gotoxy(33,6) ;
cout <<"Ticket no. " <<tno ;
gotoxy(17,9) ;
cout <<from <<" to " <<to ;
gotoxy(45,9) ;
cout <<"Flight no. " <<pfltno ;
gotoxy(20,11) ;
cout <<"Passanger Name : " <<pname ;
gotoxy(20,13) ;
cout <<"Address : " <<paddress ;
gotoxy(20,15) ;
cout <<"Sex : " <<psex ;
gotoxy(20,17) ;
cout <<"Age : " <<page ;

gotoxy(45,19) ;
if (pclass == 'E')
cout <<"Total Fair: " <<ecofair ;
else
cout <<"Total Fair: " <<exefair ;
p.ADD_RECORD(tno,sno,pname,paddress,page,psex,pclass) ;
getch() ;
}
void PASSANGER :: ADD_RECORD(int tno, int sno, char pname[26], char
paddress[36], int page, char psex, char pclass)
{
fstream file ;
file.open("PASS.DAT", ios::app) ;
ticketno = tno ;
slno = sno ;
strcpy(name,pname) ;
strcpy(address,paddress) ;
age = page ;
sex = psex ;
Class = pclass ;
file.write((char *) this, sizeof(PASSANGER)) ;
file.close() ;
}
int PASSANGER :: LAST_TICKETNO(void)
{
fstream file ;
file.open("PASS.DAT", ios::in) ;
int count=0 ;
while (file.read((char *) this, sizeof(PASSANGER)))

count = ticketno ;
file.close() ;
return count ;
}
int PASSANGER :: SEATS(int sno)
{
fstream file ;
file.open("PASS.DAT", ios::in) ;
int count=0 ;
while (file.read((char *) this, sizeof(PASSANGER)))
{
if (sno == slno)
count++ ;
}
file.close() ;
return count ;
}

int PASSANGER :: FOUND(int tno)


{
fstream file ;
file.open("PASS.DAT", ios::in) ;
int found=0 ;
while (file.read((char *) this, sizeof(PASSANGER)))
{
if (tno == ticketno)
{
found = 1 ;

break ;
}
}
file.close() ;
return found ;
}
char *PASSANGER :: NAME(int tno)
{
fstream file ;
file.open("PASS.DAT", ios::in) ;
while (file.read((char *) this, sizeof(PASSANGER)))
{
if (tno == ticketno)
break ;
}
file.close() ;
return name ;
}
void PASSANGER :: LIST(void)
{
clrscr() ;
char t1[10] ;
int t2, sno, valid ;
TICKET ticket ;
ticket.ENQUIRY() ;
do
{
valid = 1 ;

gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"PRESS <ENTER> TO EXIT" ;
gotoxy(3,20) ;
cout <<"

";

gotoxy(3,20) ;
cout <<"Enter Sno. of the FLIGHT for which you want to see list of passanger " ;
gets(t1) ;
t2 = atoi(t1) ;
sno = t2 ;
if (strlen(t1) == 0)
return ;
if (sno < 1 || sno > 12)
{
valid = 0 ;
gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
int row=7, found=0, flag=0 ;
char ch ;
DRAW d ;
d.BOX(1,2,80,24,218) ;

d.LINE_HOR(2,79,4,196) ;
d.LINE_HOR(2,79,6,196) ;
d.LINE_HOR(2,79,22,196) ;
gotoxy(3,3) ;
cout <<"Flight no. " <<ticket.FLIGHTNO(sno) ;
gotoxy(32,3) ;
cout <<"LIST OF PASSANGER" ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(2,5) ;
cprintf(" TICKET NO.

NAME

CLASS

textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
fstream file ;
file.open("PASS.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(PASSANGER)))
{
if (sno == slno)
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(5,row) ;
cout <<ticketno ;
gotoxy(17,row) ;
cout <<name ;
gotoxy(49,row) ;
if (Class == 'X')
cout <<"Executive" ;

") ;

else
cout <<"Economic" ;
if ( row == 21 )
{
flag = 1 ;
row = 7 ;
gotoxy(5,23) ;
cout <<"Press any key to continue or Press <ESC> to exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
d.BOX(1,2,80,24,218) ;
d.LINE_HOR(2,79,4,196) ;
d.LINE_HOR(2,79,6,196) ;
d.LINE_HOR(2,79,22,196) ;
gotoxy(32,3) ;
cout <<"LIST OF PASSANGER" ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(2,5) ;
cprintf(" TICKET NO.

NAME

FLIGHT NO.

textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
}
else
row++ ;
}
}
if (!found)

CLASS

") ;

{
gotoxy(5,10) ;
cout <<"\7Records not found" ;
}
if (!flag)
{
gotoxy(5,23) ;
cout <<"Press any key to continue..." ;
getch() ;
}
file.close() ;
}
void PASSANGER :: DELETE_TICKET(int tno)
{
fstream file ;
file.open("PASS.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{
file.read((char *) this, sizeof(PASSANGER)) ;
if (file.eof())
break ;
if (tno != ticketno)
temp.write((char *) this, sizeof(PASSANGER)) ;
}
file.close() ;

temp.close() ;
file.open("PASS.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(PASSANGER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(PASSANGER)) ;
}
file.close() ;
temp.close() ;
}
int PASSANGER :: DELETE_FLIGHT(int sno)
{
fstream file ;
file.open("PASS.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
int found = 0 ;
while (!file.eof())
{
file.read((char *) this, sizeof(PASSANGER)) ;
if (file.eof())

break ;
if (sno != slno)
temp.write((char *) this, sizeof(PASSANGER)) ;
else
found = 1 ;
}
file.close() ;
temp.close() ;
file.open("PASS.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(PASSANGER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(PASSANGER)) ;
}
file.close() ;
temp.close() ;
return found ;
}
void RESERVE :: CANCELLATION(void)
{
clrscr() ;
char t1[10], ch ;
int t2, tno, valid ;
do

{
valid = 1 ;
gotoxy(3,23) ; clreol() ;
cout <<"PRESS <ENTER> TO SEE LIST or 0 TO EXIT" ;
gotoxy(3,20) ; clreol() ;
cout <<"Enter Ticket no. of the Passanger to cancel the Ticket " ;
gets(t1) ;
t2 = atoi(t1) ;
tno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
LIST() ;
clrscr() ;
}
if (!FOUND(tno) && valid)
{
valid = 0 ;
gotoxy(3,23) ; clreol() ;
cout <<"\7Record not found" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
fstream file ;
file.open("PASS.DAT", ios::in) ;

while (file.read((char *) this, sizeof(PASSANGER)))


if (ticketno == tno)
break ;
file.close() ;
int i=1 ;
file.open("TICKET.DAT", ios::in) ;
while (file.read((char *) this, sizeof(TICKET)))
{
if (slno == i)
break ;
i++ ;
}
file.close() ;
PASSANGER p ;
DRAW d ;
d.BOX(15,5,66,21,'*') ;
d.LINE_HOR(16,65,7,'*') ;
gotoxy(33,6) ;
cout <<"Ticket no. " <<tno ;
gotoxy(17,9) ;
cout <<from <<" to " <<to ;
gotoxy(45,9) ;
cout <<"Flight no. " <<fltno ;
gotoxy(20,11) ;
cout <<"Passanger Name : " <<p.NAME(tno);
gotoxy(20,13) ;
cout <<"Address : " <<address ;
gotoxy(20,15) ;

cout <<"Sex : " <<sex ;


gotoxy(20,17) ;
cout <<"Age : " <<age ;
gotoxy(45,19) ;
if (Class == 'E')
cout <<"Total Fair: " <<ecofair ;
else
cout <<"Total Fair: " <<exefair ;
do
{
gotoxy(10,23) ; clreol() ;
cout <<"Cancel this ticket (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
DELETE_TICKET(tno) ;
gotoxy(10,25) ;
cout <<"\7Ticket Cancelled" ;
getch() ;
}
void RESERVE :: DISPLAY_TICKET(void)
{
clrscr() ;
char t1[10], ch ;
int t2, tno, valid ;
do

{
valid = 1 ;
gotoxy(3,23) ; clreol() ;
cout <<"PRESS <ENTER> TO SEE LIST or 0 TO EXIT" ;
gotoxy(3,20) ; clreol() ;
cout <<"Enter Ticket no. of the Passanger " ;
gets(t1) ;
t2 = atoi(t1) ;
tno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
LIST() ;
clrscr() ;
}
if (!FOUND(tno) && valid)
{
valid = 0 ;
gotoxy(3,23) ; clreol() ;
cout <<"\7Record not found" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
fstream file ;
file.open("PASS.DAT", ios::in) ;

while (file.read((char *) this, sizeof(PASSANGER)))


if (ticketno == tno)
break ;
file.close() ;
int i=1 ;
file.open("TICKET.DAT", ios::in) ;
while (file.read((char *) this, sizeof(TICKET)))
{
if (slno == i)
break ;
i++ ;
}
file.close() ;
PASSANGER p ;
DRAW d ;
d.BOX(15,5,66,21,'*') ;
d.LINE_HOR(16,65,7,'*') ;
gotoxy(33,6) ;
cout <<"Ticket no. " <<tno ;
gotoxy(17,9) ;
cout <<from <<" to " <<to ;
gotoxy(45,9) ;
cout <<"Flight no. " <<fltno ;
gotoxy(20,11) ;
cout <<"Passanger Name : " <<p.NAME(tno);
gotoxy(20,13) ;
cout <<"Address : " <<address ;
gotoxy(20,15) ;

cout <<"Sex : " <<sex ;


gotoxy(20,17) ;
cout <<"Age : " <<age ;
gotoxy(45,19) ;
if (Class == 'E')
cout <<"Total Fair: " <<ecofair ;
else
cout <<"Total Fair: " <<exefair ;
gotoxy(10,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}
void RESERVE :: DELETE_ALL(void)
{
clrscr() ;
ENQUIRY() ;
char t1[5] ;
int t2, valid, sno ;
do
{
valid = 1 ;
gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"PRESS <ENTER> TO EXIT" ;
gotoxy(3,20) ;
cout <<"
gotoxy(3,20) ;

";

cout <<"Enter Sno. of the FLIGHT for which all passanger records to be
deleted : " ;
gets(t1) ;
t2 = atoi(t1) ;
sno = t2 ;
if (strlen(t1) == 0)
return ;
if (sno < 1 || sno > 12)
{
valid = 0 ;
gotoxy(3,23) ;
cout <<"

";

gotoxy(3,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
gotoxy(3,23) ;
if (!DELETE_FLIGHT(sno))
cout <<"\7Records not found. Press any key to continue..." ;
else
cout <<"\7Records deleted. Press any key to continue..." ;
getch() ;
}

void main(void)
{

textcolor(LIGHTBLUE+BLINK) ;
delay(2000);
cout<<"\n\n\t\t\a\aWELCOME TO COMPUTERISED AIRLINE RESERVATION SYS...";
getch();
DRAW d ;
PASSANGER p ;
TICKET ticket ;
RESERVE r ;
ticket.ADDITION() ;
char ch ;
while (1)
{
clrscr() ;
d.BOX(19,6,62,20,218) ;
textcolor(BLACK) ;
textbackground(WHITE) ;
for (int i=7; i<=19; i++)
for (int j=20; j<=61; j++)
{
gotoxy(j,i) ;
cprintf(" ") ;
}
gotoxy(29,9) ;
cprintf("AIR TICKET RESERVATION") ;
gotoxy(29,10) ;
cprintf("~~~~~~~~~~~~~~~~~~~~~~") ;
gotoxy(30,11) ;
cprintf("1: RESERVATION") ;

gotoxy(30,12) ;
cprintf("2: CANCELLATION") ;
gotoxy(30,13) ;
cprintf("3: PASSENGER RECORDS ->") ;
gotoxy(30,14) ;
cprintf("4: ENQUIRY") ;
gotoxy(30,15) ;
cprintf("5: LIST OF PASSENGERS") ;
gotoxy(30,16) ;
cprintf("6: QUIT") ;
gotoxy(30,18) ;
cprintf("ENTER YOUR CHOICE ") ;
ch = getche() ;
textcolor(LIGHTGRAY) ;
textbackground(BLACK) ;
clrscr() ;
if (ch == 27 || ch == '6')
break ;
else
if (ch == '1')
r.RESERVATION() ;
if (ch == '2')
r.CANCELLATION() ;
if (ch == '4')
{
ticket.ENQUIRY() ;
gotoxy(2,23) ;
cout <<"Press any key to continue..." ;

getch() ;
}
else
if (ch == '5')
p.LIST() ;
else
if (ch == '3')
{
while (1)
{
clrscr() ;
d.BOX(19,6,62,20,218) ;
textcolor(BLACK) ;
textbackground(WHITE) ;
for (int i=7; i<=19; i++)
for (int j=20; j<=61; j++)
{
gotoxy(j,i) ;
cprintf(" ") ;
}
gotoxy(29,10) ;
cprintf("EDIT PASSENGER RECORDS") ;
gotoxy(29,11) ;
cprintf("~~~~~~~~~~~~~~~~~~~~~~") ;
gotoxy(33,12) ;
cprintf("1: PASSANGER INFORMATION") ;
gotoxy(33,13) ;
cprintf("2: DELETE") ;

gotoxy(33,14) ;
cprintf("0: EXIT") ;
gotoxy(31,16) ;
cprintf("ENTER YOUR CHOICE ") ;
ch = getche() ;
textcolor(LIGHTGRAY) ;
textbackground(BLACK) ;
clrscr() ;
if (ch == 27 || ch == '0')
break ;
else
if (ch == '1')
r.DISPLAY_TICKET() ;
else
if (ch == '2')
r.DELETE_ALL() ;
}}}
#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
struct components{int ch;
char choice;}c1;
struct country{char n[20];
char c[20];
float income;
};

void inst()
{
cout<<"The structure elements of a structure can be initialised either
seperately,using separate assignment statementsorjointly using the notation
similar to array initialisation.\n";
cout<<"Example:-\nstudent.rollno=07;\nstudent.class=11;\nstudennt.marks=50
;\nstudent.grade='A';\n";
cout<<"\a\a\a\a\a\tAlternatively,the structure 'student' can be initialised by
using the notation used for array initialisation as shown below:\ns1
student={01,11,50.00.'A'};";
}
void stas()
{
cout<<"Objects of structure types can be assigned,passed as function
arguments,and returned as the result from the
function.\nExample:-\njunior_student=senior_student;\n";
cout<<"Note that one structure variable can be assigned to other only when
they are of similar data types.If not the compiler will show the
error.\nExample:-\njunoir_student=birth_date;\n";
}
void nest()
{
cout<<"A structure can be nested inside another structure,such structures are
called complex strucures.\n";
cout<<"Let us take an example for this in the following code:-\n";
cout<<"struct addr{int houseno;\nchar area[26];\nchar city[26];\nchar
state[26];};\nstruct emp{int empno;\nchar name[26];\nchar desig[16];\naddr
address;\t\\like this\nfloat basic;\n} worker;\nint main()\n{cout<<''Enter employ
number'';\ncin>>worker.empno;\ngets(worker.name);\ngets(worker.desig);\ncin>
>worker.address.houseno;\ngets(worker.address.area);\ngets(worker.address.city
);\ncin>>worker.basic;\nreturn 0;\n}\n";
}
void opt()
{

cout<<"Enter Employee no:\n103\nName :Neel\nDesignation :Manager\nEnter


address:\nHouse no:323\nArea :Dwarka\nCity :New Delhi\nState :Delhi\nBasic
Pay :25000\n";
}
void sna()
{
cout<<"Since an array can contain similar elements, the combination having
structures within an array is an array of structures.To declare an array of
structures, you must first define a structure and then declare an array variable of
that type.\nFor example:-\nAddr mem_addr[100];\n";
cout<<"Example implementing array of structures:-\n";
cout<<"struct country{char n[20];\nchar c[20];\nfloat income;\n}\nvoid
func(country c[5],char con[20])\n{\nfor(int i=0;i<5;+
+i)\n{if(strcmp(c[i].n,con)==0)\ncout<<c[i].cp<<c[i].income;\n}\n}\nvoid
main()\n{country c[5];\nchar con[20];\nfor(int i=0;i<5;+
+i)\n{\ncin>>c[i].n>>c[i].cp>>c[i].income;\n}\ngetch();\n}";
}
void opt2(country c[5],char con[20])
{

for(int i=0;i<5;++i)
{if(strcmp(c[i].n,con)==0)
cout<<"\n"<<c[i].c<<"\n"<<c[i].income;
}
}

void main()
{ clrscr();
char con[20];
country c[5];
cout<<"Chapter 13:-Structures.\n";
cout<<"A structure is a collection of similar or dissimilar data types.";

cout<<"Example:-\nstruct hk{int ch;\nchar choice;}c1;\n";


cout<<"Menu:-\n1.Initialising Structures.\n2.Structures Assignment.\n3.Nested
Structures.\n4.Structures & Arrays.\n";
cin>>c1.ch;
switch(c1.ch)
{
case 1:inst();
break;
case 2:stas();
break;
case 3:nest();
cout<<"Do you want to see the output?<y/n>\n";
cin>>c1.choice;
if(c1.choice=='y')
{ opt();
}
else
cout<<"\a\aExiting.......................\a\a\a\a\a\a";
exit(0);
break;
case 4:sna();
cout<<"Do you want to see the output of the above program?
<y/n>\n";
cin>>c1.choice;
if(c1.choice=='y')
{
for(int i=0;i<5;++i)
{cin>>c[i].n>>c[i].income;
}

opt2(c,con);
}
else
cout<<"\a\aExiting.........................\a\a\a\a\a\a\a\a\a";
break;
}
getch();
}

#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
void oper()
{cout<<"\nOperator:\n";
cout<<"It is defined as the operations are representd by the operators and the
objects are referred to as operand\n\n";

}
void arith()

{ int ch;
cout<<"Arithmetic operators\n";
delay(1200);
cout<<"It provides operations for five basic arithmetic
calculations:addition,subtraction,multiplication,division and remainder
respectively.\n";
cout<<"There are different types of operators\n";
delay(1200);
cout<<"1.Unary Operators\n2.Binary operators\n3.Ternary operators \n4.logical
operators\n5.Type conversion\n6.exit\n";
cout<<"enter your choice\n";
cin>>ch;
switch(ch)
{case 1:cout<<"unary Operators\n";
cout<<"It act upon one operands\n";
cout<<"Example implementing all unary operators\n";
int n,i=1,sum=0;
cout<<"enter the value of n:";
cin>>n;
cout<<"n first"<<n<<"natural numbers are :nn";
do
{
cout<<i;
sum=sum+i;
i++;
}
while(i<=n);
cout<<"nn sum="<<sum;
break;

case 2:cout<<"Binary operators\n";


cout<<"It act on two operand \n";
cout<<"Exampal implementing all binary Operators\n";
char choi;
float l,b,area,perimeter;
cout<<"\n rectangle menu";
cout<<"\n 1.Area";
cout<<"\n 2.Perimeter";
cout<<"\n 3.exit"<<"\n";
cout<<"enter your choice";
do
{cin>>choi;
if((choi=='1')||(choi=='2'))
{
cout<<"enter the value of length and breadth";
cin>>l>>b;}
switch(choi)
{ case'1':area=l*b;
cout<<"area"<<area;
break;
case'2':perimeter=2*(l+b);
cout<<"perimeter"<<perimeter;
break;
default:cout<<"wrong menu";
cout<<"\n want to continue(y/n)?";
cin>>choi;}}
while((choi=='y')||(choi=='y'));
break;

case 3:cout<<"Ternary operators\n";


cout<<"It act upon three operands\n";

break;
case 4:cout<<"Logical operators \n";
cout<<"These are ||(logical Or),&&(Logical AND) and! (logical NOT)\n";
cout<<"Example implementing logical operators\n";
int rem;
cout<<"enter the number";
cin>>n;
while(n!=0)
{
rem=n%10;
sum+=rem;
n/=10;
}
cout<<"the sum of the digits of the number is "<<sum;
break;
case 5:char chi;
cout<<"Type conversion\n";
cout<<"It is a process of converting one predefined type into another\n";
cout<<"There are two types of conversion \n";
cout<<"a.Implicit type conversion\nb.Explicit type conversion\n";
cin>>chi ;
switch(chi)
{case 'a':cout<<"Implicit type conversion\n";
cout<<"It is a conversion performed by the compiler without programmer's
intervention.\n";
break;

case 'b':cout<<"Explicit type conversion\n";


cout<<"It is user defined that forces an expression to be of specific type\n";
break;
default :cout<<"wrong choice\n";
}
}
}
void main()
{clrscr();
cout<<"Chapter 8:Operators and expression in c++\n";
oper();
arith();
getch();
}

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<process.h>
#include<dos.h>
void inte()
{cout<<"Example of int data type ........\n";
int dividend,divisor,rem,hcf;
cout<<"enter two numbers:";
cin>>dividend>>divisor;
while(rem!=0)
{rem=dividend%divisor;

if(rem==0)
hcf=divisor;
else
{dividend=divisor;
divisor=rem;
}}
cout<<"hcf is:"<<hcf;
}

void chara()
{cout<<"Example of char data types are........\n";
char ch;
cout<<"Enter character between a to j\n";
cin>>ch;
int num=ch;
cout<<char(num+1);
cout<<" "<<char(num+2);
cout<<" "<<char(num+3);
cout<<" "<<char(num+4);

void flo()
{cout<<"example of float data types....\n";
int r;
cin>>r;
cout<<"radius of circle="<<r;
float z=(r*r)*22/7;

cout<<"\narea of circle having radius "<<r<<"cm="<<z;


}
void doubl()
{cout<<"example of double data types.........\n";
double a,b,c,d,e;
char name[20];
cin>>name;
cout<<"Marks of "<<name<< " in all 5 subjects out of 100";
cout<<"\nMarks in english=";
cin>>a;
cout<<"Marks in maths=";
cin>>b;
cout<<"Marks in hindi=";
cin>>c;
cout<<"Marks in science=";
cin>>d;
cout<<"Marks in social science=";
cin>>e;
float z=(a+b+c+d+e)/5;
cout<<"average marks="<<z;
}
void arr()
{cout<<"Array:\nIt is a collection of similar & dissimilar values of some data
types.";
cout<<"Example implimenting array......................\n";
cout<<"void main()\n{clrscr();\nint arr[5];\n cout<<'enter the
val';\ncin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>arr[4];\ncout<<arr[0]<<arr[1]<
<arr[2]<<arr[3]<<arr[4];\n}";}
void func()

{int f1;
cout<<"Function:\n"<<"It is the method or concept for implementing modularity
in C++ programming\n";
cout<<"There are two types of function:\n1.User defined \n2.Predefined\n";
cin>>f1;
switch(f1)
{case 1:cout<<"User defined:Function defined by the user for specific
purpose\n";
cout<<"Declaration:\neg:-void function()";
break;
case 2:cout<<"Pre-defined function.\n eg:-cout,cin"; }
}
void point()
{cout<<"pointer:\n"<<"It is a variable that stores the address of the another
variable as its content";
cout<<"Example implementing pointers\n";
cout<<"Void main()\n{clrscr();\nint
*ptr,a=10;\nptr=$a;\ncout<<ptr;\ncout<<*ptr";
}
void refer()
{cout<<"Reference:\n"<<"It is to give an alternate name to the same memory
location.i.e,same memory accesed using two different variable names";
cout<<"Example implementing reference......\n";
cout<<"#include<iostream.h>\n#include<conio.h>\nvoid X(int &A,int
&B)\n{A=A+B;\nB=A-B;\nA=A-B;}\nvoid main()\n{clrscr();\nint
a=4,b=18;\nX(a,b);\ncout<<a<<","<<b;\ngetch();\n}\n";
}
void cla()
{cout<<"A class represents a group of similar objects.\n";
cout<<"Example of class...........\n";

cout<<"class book\n{int bookno;\nchar bookname[];\nfloat price;\nint


bookblist[5];\n};\nPublic:\nadd();\ndelete();\nmodify();\nprint();\n};\n";
}
void str()
{cout<<"Example of structure are.....\n";
cout<<"struct components{int ch;\n\tchar choice;}c1;\nstruct country{char
n[20];\n\t\tchar c[20];\n\t\tfloat income;\n\t\t};\n";
}
void un()
{cout<<"A union is a memory location that is shared by two or more different
variables,generally of different types at different times\n";
cout<<"Note that...........\n";
delay(1200);
cout<<"1.The keyword union is used for declaring and creating a union.\n";
cout<<"2.In union cnvt,both integer i and character ch share the same memory
location\n";
cout<<"Using union\n";
cout<<"To assign the integer 20 to element i of cnvt......we write.......\n";
delay(1000);
cout<<"cnvt.i=20\n";
}
void enu()
{cout<<"An alternative method for naming integer constants is often more
convenient than const.This can be achieved by creating enumeration using
keywords enum.\n";
cout<<"Example is.....\n\t\t\t";
cout<<"enum{START,PAUSE,GOO)";
}
void main()
{clrscr();
int ch;

char T,man,deb;
char choice;
cout<<"Chapter 7:Data Handling.\n";
delay(1880);
cout<<"There are three types of data types:\n1.Fundamental data
types\n2.Derived data type\n3.User defined data types\n";
cin>>ch;
switch(ch)
{case 1:cout<<"Fundamental data types \n";
cout<<"Fundamental data types are those that are not compose of
other data types\n";
cout<<"They are of different types ..........\n";
cout<<"a.int data types\nb.char data types.\nc.float data
type\nd.double data types.\ne.void data type\n";
cin>>man;
if(man=='a')
{inte();
}
else
if(man=='b')
{chara();
}
else
if(man=='c')
{
flo(); }
else
if(man=='d')
{doubl();}

break;

case 2:cout<<"\t\tThere are different types of derived data types.\n";


cout<<"a.Array.\nb.Functions.\nc.Pointers\nd.Reference\ne.Constants\n";
cin>>choice;
if(choice=='a')
arr();
if(choice=='b')
func();
if(choice=='c')
point();
break;
case 3:cout<<"\t There are different types of user defined data types\n";
cout<<"a.class\nb.structure\nc.union\nd.Enumeration\m";
cin>>deb;
if(deb=='a')
cla();
if(deb=='b')
str();
if(deb=='c')
un();
if(deb=='d')
enu();
}
getch();
}

#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
void main()
{
textmode(C80);
textcolor(GREEN);
textbackground(BLUE);
clrscr();
char ch;
cout<<"\t\t\nW\a-e\a-l\a-c\a-o\a-m\a-e t\a-o\a- c\a-h\a-a\a-p\a-t\a-e\a-r\a66\n"<<""<<"\t\tGetting started with c++\t\t"<<""<<"\n";
gotoxy(9,5);
label:

clrscr();
cout<<"1.Keyword\n"<<"2.Literals\n"<<"3.Identifires\n"<<"4.punctutors\n"<<"
5.Operators\n6.Exit\n";
cout<<"enter your choice\n";
cin>>ch;
switch(ch)
{ char q,e;
case '1':cout<<"Keyword\n";
cout<<"keyword is tokens in which Reserved word having special
meaning and purpose.These reservedfor special purpose and must not be used
as normal identifire names. \n";
cout<<"The example of Keywords are:-\n";
cout<<"asm\tcontinue\tfloat\tnew\tsigned\ttry\t\nauto\tdefault\tfor\toperator\tsiz
eof\ttypedef\t\nbreak\tdelete\tfriend\tprivate\tstatic\tunion\t\ncase\tdo\tgoto\tpro
tected\tstruct\t\n";
cout<<"\n\n To exit to main menu\n\t Press e\n";
cin>>q;
if( q=='e')
{

goto label;

}
break;
case '2':cout<<"Literals\n";
cout<<"Literals are constant that are assigned value and the fixed
literals do not change their value during the program expression\n";
cout<<"Literals are of various types \n";
cout<<"a.bool literals\n"<<"b.interger constants\n"<<"c.character
constants\n"<<"d.string literals\n";
cout<<"enter your choice\n";
cin>>ch;
switch(ch)

{case 'a':cout<<"bool literals\n";


cout<<"A bool literals can be assined a value true or false as a
result of an expression\n";
cout<<"\tOne of the example of bool literals\n";
{int x,y;
cout<<"enter the value of x and y\n";
cin>>x>>y;
if(x>y)
cout<<"x is greater\n";
else
cout<<"y is greater";
}
break;
case 'b':cout<<"Integer constant\n";
cout<<"they are whole no. without any fractioal part. Integer are
represent internally depending upon a number system\n";
cout<<"Example are.....\n";
cout<<"void main()\n{int x=5,y=6;\n cin>>x>>y;\n
if(x>y)\ncout<<''x is greater'';\nelse\ncout<<''y is greater'';\n";
cout<<"\n here in this example X and Y are integer constants\n";
cout<<"they are of different types \n";
cout<<"1.decimal\n"<<"2.octal\n"<<"3.hexadecimal";
break;
case 'c':cout<<"character constant\n";
cout<<"A character constant is a character value enclosed with
single quotes\n";
cout<<"EXample are..........\n";
delay(1000);
cout<<"'c' or 'A' have type char which is a C++ data type for
characters.The value of a single character constant is the numerical value of the
character\t";

cout<<"in the meaning's character set.The value for 'c' will be 99


which is ascii value of c and the value of 'A' will be 65 which is ASCII value of
A\n";
cout<<"Escape sequences are non graphical char that can not be
typed from the keybord.An escape sequence is represented by a backslash(\)
followed by one or more characters\n";
break;
case 'd':cout<<"string literals\n";
cout<<"It is a group of char inclosed within a double cords\n";
cout<<"Multiple character constants are treated as string
literals.Each string literals is by default added with a special character'\o' which
makes the end of strings.\n";
cout<<"Example implementing strings literals are............\n";
cout<<"#include<iotsream.h>\n#include<conio.h>\nvoid
main()\n{char Msg[]=''Sunset Gardens'';\nclrscr();\nfor(int i=0;i<strlen(Msg);i+
+)\n{for(int j=0;j<=1;++j)\n{cout<<Msg[i]; }\ncout<<endl;}\ngetch();}\n";
break;

default:cout<<"wrong choice!!!!!!!";}
break;
case '3':cout<<"Identifiers\n";
cout<<"It is the fundamental building blocks of program and are
used as the general terminology for the names given to different parts of the
program viz.variables,objects,classes,functions,arrays etc.\n";
cout<<"C++ is a case sensitive as it treats upper and lower case
character differently.\n";
cout<<"The identifire which are valid.......................\n";
delay(1100);
cout<<"\nMyfile\tDate9_77\tZ2t0i9\nMYFILE\t_DS\t_HIJK_14\nCHK\tFILE13\n";
cout<<"The identifire which are not valid..................\n";
delay(1200);

cout<<"DATE-REC (contains special character)\n29CLCT(starting with


a digit)\nbreak(reserved keywords)\nMy.file(contains special character dot(.)\n";
break;
case '4':cout<<"punctutors\n";
cout<<"puncutors is a seperator in which statements may be
seperated \n";
cout<<"There are different types of Punctuators.......\n";
cout<<"1.Brackets[]\n2.Parentheses()\n3.Braces{}\n4.comma,\n5.semicolon;\n6
.colon:\n7.Asterisk*\n8.Ellipsis....\n9.Eual to sign=\n10.Pound sign #\n";
cout<<"We can easily understand these punctuators by using
program.....\n";
cout<<"#include<iostream.h>\n#include<conio.h>\n#include<process.h>\nvoi
d convert(float & d,char & t,char ch)\n{switch(ch)\n{case
'f':if(t=='i')\n{d=d/12;\nt='f';}\nbreak;\ncase
'i':if(t=='f')\n{d=d*12;\nt='i';}\nbreak;}\nreturn;}\nint main()\n{clrscr();\nfloat
distance;\nchar choice,type='f';\nfirst:\ncout<<\n''enter distance in
feet:'';\ncin>>distance;\ncout<<\n''you want distance in feet or inches?
(f/i):''\n;\ncin>>choice\nswitch(choice)\n{case'f':convert(distance,type,'f');\nbrea
k;\ncase'i':convert(distance,type,'i');\nbreak;\ndefault:cout<<\n''you have
entered a wrong choice!!!!!!!!!!!!!!!!!!!!'';\ngoto
first;}\ncout<<\n''distance=''<<distance<<'' ''<<type<<'\n;''\ngetch();\nreturn
0;}\n";

break;
case '5':cout<<"operators\n";
cout<<"operators are categorise\n";
cout<<"1.urnary operators\n"<<"2.binary operators\n"<<"2.Ternary
operators";
cout<<"The example of binary operators are........\n";
cout<<"#include<iostream.h>\n#include<conio.h>\nvoid
manish(int x,int y)\n{int s;\ns=x+y;\ncout<<''the sum is\t''<<s<<''\n'';\nint
sub;\nsub=x-y;\ncout<<''the substract is\t''<<sub<<''\n'';\nint
mul;\nmul=x*y;\ncout<<''the multiply is\t''<<mul<<\n;\nfloat
div;\ndiv=x/y;\ncout<<''the division is\t''<<div;\n}\nvoid
main()\n{\nclrscr();\nint x,y;\ncout<<''enter the value of x and
y\n'';\ncin>>x>>y;\nmanish(x,y);\ngetch();\n}";

break;
case '6':exit(0);

default:cout<<"user has chossen wrong choice\n";


goto label;
}
getch();
}

#include<iostream.h>
#include<conio.h>
#include<process.h>
struct rail{ int pseat;
char pname[20];
float pfare;
char pbirth;
char pcomp;
}r1[3];
void rail()

{for(int i=0;i<3;i++)
{cout<<"\tThe passenger number\t"<<i+1;
cout<<"\n\tEnter the passenger name\t";
cin>>r1[i].pname;
cout<<"\n\tEnter the passenger compartment\n";
cin>>r1[i].pcomp;
cout<<"\n\tEnter the passenger seat\n";
cin>>r1[i].pseat;
cout<<"\n\tEnter the passenger fare\n";
cin>>r1[i].pfare;
cout<<"\n\tEnter the passenger birth\n";
cin>>r1[i].pbirth; }
}
void display()
{for(int i=0;i<3;i++)
{if(r1[i].pfare>1000)
cout<<"\n\tThe passenger seat is :\tReserved\n";
cout<<"\n\tThe passenger name is:"<<r1[i].pname<<endl;
cout<<"\n\tThe passenger fare is:"<<r1[i].pfare;
cout<<"\n\tThe passenger compartment is:"<<r1[i].pcomp;
cout<<"\n\tThe passenger birth is:"<<r1[i].pbirth;
cout<<endl;
}
}
void main()
{clrscr();
rail();
display();

getch();
}

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<process.h>
struct components{int ch;
char choice;
}c1;
void cls()
{cout<<"Class:\nIt is group of similar object";
cout<<"Example implementing class\n";
cout<<"\nclass_student-\n{private :\nint adm;\nchar name[x];\nchar sec;\nint
class;\npublic:\nvoid my function();};";

}
void stru()
{cout<<"Structure:\nIt is a heterogenous collection of fundamental and derived
types refer by a common name'struct'.";
cout<<"\nExample implementing structure";
cout<<"\nstruct student\n{int adm no;\nchar name[n];\nint cl;\nfloat avg;\nch
sec\n}";
}
void arr()
{cout<<"Array:\nIt is a collection of similar & dissimilar values of some data
types.";
cout<<"Example implimenting array......................\n";
cout<<"void main()\n{clrscr();\nint arr[5];\n cout<<'enter the
val';\ncin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>arr[4];\ncout<<arr[0]<<arr[1]<
<arr[2]<<arr[3]<<arr[4];\n}";}
void func()
{int f1;
cout<<"Function:\n"<<"It is the method or concept for implementing modularity
in C++ programming\n";
cout<<"There are two types of function:\n1.User defined \n2.Predefined\n";
cin>>f1;
switch(f1)
{case 1:cout<<"User defined:Function defined by the user for specific
purpose\n";
cout<<"Declaration:\neg:-void function()";
break;
case 2:cout<<"Pre-defined function.\n eg:-cout,cin"; }
}
void point()
{cout<<"pointer:\n"<<"It is a variable that stores the address of the another
variable as its content";

cout<<"Example implementing pointers\n";


cout<<"Void main()\n{clrscr();\nint
*ptr,a=10;\nptr=$a;\ncout<<ptr;\ncout<<*ptr";
}
void refer()
{cout<<"Reference:\n"<<"It is to give an alternate name to the same memory
location.i.e,same memory accesed using two different variable names";
cout<<"Example implementing reference\n";
cout<<"char ch='A';\n char &ch=cl;\n";
}
void cons()
{cout<<"Constant :"<<"It is a variable whose value remains same throughout
the program\n";
cout<<"Example:-\n int x =5";
}

void main()
{clrscr();
cout<<"Chapter 7:Data Handling.\n";
clrscr();
cout<<"There are two types of data types:\n1.Derived data type\n2.User defined
data types\n";
cin>>c1.ch;
switch(c1.ch)
{case 1:cout<<"\t\tThere are different types of derived data types.\n";
cout<<"a.Array.\nb.Functions.\nc.Pointers\nd.Reference\ne.Constants\n";
cin>>c1.choice;
if(c1.choice=='a')
arr();
if(c1.choice=='b')

func();
if(c1.choice=='c')
point();
if(c1.choice=='d')
refer();
if(c1.choice=='e')
cons();
break;
case 2:cout<<"There are two types of user defined data types.\n";
cout<<"a.Class.\n b.Structure\n";
cin>>c1.choice;
if(c1.choice=='a')
cls();
if(c1.choice=='b')
stru();
}

getch();

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<string.h>
struct Stru{char a4[6];
char first[18];
char second[15];
char email[25];
char pswrd1[19];
}h;
void function();

void function()
{
}
void main()
{int i;
char pswrd[]="computer";
char a1[]="Sign up";
char a2[]="Login";
textbackground(BLUE);
clrscr();
textcolor(WHITE);
char a3[]="Welcome to Facebook.\n";
for(int b3=0;b3<=strlen(a3);b3++)
{cout<<a3[b3];
delay(50);
}
gotoxy(5,4);
cprintf("Login\nSign up");
textcolor(WHITE);
cout<<"\nEnter your choice\n";
gets(h.a4);
if(strcmp(h.a4,a1)==0)
{textbackground(BLUE);
clrscr();
textcolor(WHITE);
gotoxy(7,7);
cout<<"Sign up\n It's free and always will be.\n";
cprintf("First Name_______________\n");

gotoxy(16,9);
cin>>h.first;
cprintf("Surname______________\n");
gotoxy(13,10);
cin>>h.second;
cprintf("Email______________________________\n");
gotoxy(8,11);
cin>>h.email;
cprintf("Re-enter email_______________________________\n");
gotoxy(18,12);
cin>>h.email;
cprintf("New password______________________\n");
gotoxy(15,13);
cin>>h.pswrd1;
cout<<"\n \t";
cprintf("Birthday");
cout<<"\tDate____________\tMonth_____________\tYear_____\n";
}
getch();
}

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<stdlib.h>
#include<dos.h>
#include<iomanip.h>

void main()
{clrscr();
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout<<setprecision(2);
textbackground(BLACK);

textcolor(CYAN+BLINK);
clrscr();
delay(1500);
puts("LOADING");
delay(2000);
for(int i=0;i<50;i++)
{

textcolor(CYAN);
textbackground(BLACK);
clrscr();
puts("LOADING");
for(int j=0;j<i;j++)
cout<<"_w_e_l_c_o_m_e...";
for(int x=10-(i);x>0;x--)
cout<<" ";
cout<<" "<<i<<"0%";
if(i%2==0)
delay(500);
else
delay(200);

}
puts("COMPLETE");
delay(500);
getch();
}

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<ctype.h>
#include<stdio.h>
#include<process.h>
#include<iomanip.h>
#include<math.h>
#include<fstream.h>
struct addr
{int hno;
char area[20];
char city[20];
char state[20];
};
class agent

{int code_a;

//code of the agent

char name_a[20]; //name of the agent


int age_a;

//age of the agent

addr agt_add;

//address of the agent

int pol_sold;

//no of policy sold

float sal_a;

//salary of the agent

char cat_a[10];

//category of the agent

public:
void nw_agt();

//function for the new agents

void ex_agt();

//function for the existing agents

int ret_agt_cod()
{return code_a;
}
void show_det()
{
cout<<"your code\n";
cout<<code_a;
cout<<"your name\n";
puts(name_a);
cout<<"your age\n";
cout<<age_a;
cout<<"your area\n";
cout<<agt_add.area;
cout<<"your city\n";
cout<<agt_add.city;
cout<<"your state\n";
cout<<agt_add.state;
cout<<"no of policy sold\n";

cout<<pol_sold;
cout<<"your salary\n";
cout<<sal_a;
cout<<"category of the agent\n";
puts(cat_a);
}

}a;
void agent::nw_agt()
{int ch;
cout<<"please enter your details\n";
cout<<"enter your code\n";
cin>>code_a;
cout<<"enter your name\n";
gets(name_a);
cout<<"enter your age\n";
cin>>age_a;
cout<<"enter your area\n";
cin>>agt_add.area;
cout<<"enter your city\n";
cin>>agt_add.city;
cout<<"enter your state\n";
cin>>agt_add.state;
cout<<"no of policy sold\n";
cin>>pol_sold;
cout<<"enter your salary\n";
cin>>sal_a;
cout<<"category of the agent\n";

gets(cat_a);
cout<<"\n\ndo you want to save these details of the customer\n";
cin>>ch;
if(ch=='y')
{fstream f("agent_details.dat",ios::in|ios::out|ios::binary);
while(!f.eof())
{f.write((char*)&a,sizeof(agent));
}
f.close();
}
else
exit(0);
}
void agent::ex_agt()
{int sea,fg=0;
cout<<"please enter your agent code\n";
cin>>sea;
fstream f("agent_details.dat",ios::in|ios::out|ios::binary);
while(!f.eof())
{f.read((char*)&a,sizeof(agent));
if(a.ret_agt_cod()==sea)
{
cout<<"match found\n";
a.show_det();
fg=1;
break;
}
else

{if(fg==0)
cout<<"not found\n";
}
}
f.close();

}
class customer
{char name_c[20]; //name of the customer
int age_c;

//age of the customer

addr cust_add;

//address of the customer

char pol_bout[30]; //name of the policy bought


float sal_c;

//salary of the customer

int code_c;

//code of the customer

float pol_amt;

//amount of the policy

int pol_term;

//duration of policy bought if any

char mode_pay[10]; //mode of payment


float sa_pr_annum; //salary per annum
float premium;

//premium

public:
void nw_cust();

//function for the new customer

void show_det_cust()
{

cout<<"name\n";
cout<<name_c;
cout<<"age\n";
cout<<age_c;
cout<<"house no\n";
cout<<cust_add.hno;

cout<<"area\n";
cout<<cust_add.area;
cout<<"your city\n";
cout<<cust_add.city;
cout<<"your state\n";
cout<<cust_add.state;
cout<<"name of policies bought\n";
cout<<pol_bout;
cout<<"salary of the customer\n";
cout<<sal_c;
cout<<"code of the customer\n";
cout<<code_c;
cout<<"amount of the policy\n";
cout<<pol_amt;
cout<<"duration of the policy\n";
cout<<pol_term;
cout<<"the mode of payment\n";
cout<<mode_pay;
cout<<"salary per annum\n";
cout<<sa_pr_annum;
cout<<"premium\n";
cout<<premium;
}
int ret_cust_cod()
{return code_c;
}
}c;
struct feedback

{int age_f;

//age of the filler

char name_f;

//name of the filler

char gender_f[10]; //gender of the form filler


char occ_f[20];
float inc_f;

//occupation of the filler


//income of the filler

char ratings[5];

//ratings given

}fd;

void wpage();

//function to display the welcome page

void customer::nw_cust()
{ int ch2;
cout<<"Please enter your details\n";
cout<<"enter name\n";
cin>>name_c;
cout<<"enter your age\n";
cin>>age_c;
cout<<"enter your house no\n";
cin>>cust_add.hno;
cout<<"enter area\n";
cin>>cust_add.area;
cout<<"enter your city\n";
cin>>cust_add.city;
cout<<"enter your state\n";
cin>>cust_add.state;
cout<<"enter name of policies bought\n";
cin>>pol_bout;
cout<<"enter salary of the customer\n";
cin>>sal_c;

cout<<"enter code of the customer\n";


cin>>code_c;
cout<<"amount of the policy\n";
cin>>pol_amt;
cout<<"enter the duration of the policy\n";
cin>>pol_term;
cout<<"enter the mode of payment\n";
cin>>mode_pay;
cout<<"enter the salary per annum\n";
cin>>sa_pr_annum;
cout<<"enter the premium\n";
cin>>premium;
cout<<"\n\ndo you want to save these details of the customer\n";
cin>>ch2;
if(ch2=='y')
{fstream f("customer_details.dat",ios::app|ios::binary);
while(!f.eof())
{f.write((char*)&c,sizeof(customer));
}
f.close();
}
}
void main()
{clrscr();
char pass[20];int ch1=0,ch2=0,ch3=0,custco=0,agcode=0;

cout<<"\n\t\twhat do you want to do\n";

cout<<"1.view customers and their details\n2.add new customer\n3.view


agents and their details\n4.add a new agent\n5.policies and terms and
conditions\n6.Exit\n";
cin>>ch1;
if(ch1==1)
{clrscr();
cout<<"so.....u want to see details of the customer....!!!!\n";
cout<<"please enter your customer code.\n";
cin>>custco;
fstream f("customer_details.dat",ios::in|ios::binary);
while(!f.eof())
{f.read((char*)&c,sizeof(customer));
if(c.ret_cust_cod()==custco)
c.show_det_cust();
}
f.close();

cout<<"Do you want to fill the feedback form\n";


cin>>ch2;
if(ch2=='y')
{clrscr();
cout<<"enter your age\n";
cin>>fd.age_f;
cout<<"enter your gender\n";
cin>>fd.gender_f;
cout<<"enter you name\n";
cin>>fd.name_f;
cout<<"enter your occupation\n";
gets(fd.occ_f);

cout<<"enter your income\n";


cin>>fd.inc_f;
cout<<"enter your ratings\n";
cin>>fd.ratings;
}
}
else
if(ch1==2)
{clrscr();
c.nw_cust();
}
else
if(ch1==3)
{clrscr();
cin>>agcode;
a.ex_agt();
}
else
if(ch1==4)
{clrscr();
a.nw_agt();
}
else
if(ch1==5)
{clrscr();
cout<<"\n\nPOLICIES \n";
cout<<"1.Endowment policy\n";
cout<<"2.Money back policy\n3.Jeevan Rakshak\n4.Jeevan anand\n5.Jeevan
Nidhi\n";

cin>>ch3;
if(ch3==1)
{cout<<"\t\tEndowment Policy\n";
cout<<"1.Age :8 yrs(minimum)to 55 yrs(maximum)\n2.term:12 yrs to 35
yrs\n3.amount:1 lakh to no limit\n4.age proof:standard\n5.accidental
benifits:no\n";
}
else
if(ch3==2)
{clrscr();
cout<<"\t\tMoney back Policy\n";
cout<<"1.age:5 yrs to 50 yrs\n2.term:20 yrs\n3.premium paying term:15
yrs\n4.SA:5 lakhs\n5.mode:yearly/monthly\n\nNOTE:\n->Sum assured in multiple
of 10,000\n";
}
else
if(ch3==3)
{clrscr();
cout<<"\t\tJEEVAN RAKSHAK\n";
cout<<"age:8 to 55 yrs.\n2.policy term:10 to 20 yrs\n3.minimum sum
assured:75,000\n4.maximum sum assured:2 lakhs\n5.accidental
benifits:yes@0.50%\n6.mode:yearly/monthly\n";
}
else
if(ch3==4)
{clrscr();
cout<<"\t\tJEEVAN ANAND\n";
cout<<"1.age:18 to 55 yrs\n2.policy terms:15 to 35 yrs\n3.SA:1 lakhs to no
limit\n4.mode:yearly/monthly\n\nNOTE:\n->sum assured in multiple of 5000\n";
}
else

if(ch3==5)
{clrscr();
cout<<"\t\tJEEVAN NIDHI\n";
cout<<"1.age:20 to 60 yrs\n2.policy terms:7 to 35 yrs\n3.SA:1 lakh to no
limimt\n4.service tax:3.09% and 1.545%5.mode:yearly/monthly\n6.accidental
benifits:RS.1/1000 sa\n7.policy loan:no\n";
}
}
else
if(ch1==6)
{clrscr();
cout<<"\n\n\n\n\t\t\t\tTHANK YOU !!!!\n";
getch();
exit(0);
}
getch();
}

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

struct addr
{int hno;
char area[20];
char city[20];
char state[20];
};
class agent
{int code_a;

//code of the agent

char name_a[20]; //name of the agent


int age_a;

//age of the agent

addr agt_add;

//address of the agent

int pol_sold;

//no of policy sold

float sal_a;

//salary of the agent

char cat_a[10];

//category of the agent

public:
void nw_agt();

//function for the new agents

void ex_agt();

//function for the existing agents

int ret_agt_cod()
{return code_a;
}

void show_det()
{
cout<<"your code\n";
cout<<code_a;
cout<<"your name\n";
puts(name_a);
cout<<"your age\n";
cout<<age_a;
cout<<"your area\n";
cout<<agt_add.area;
cout<<"your city\n";
cout<<agt_add.city;
cout<<"your state\n";
cout<<agt_add.state;
cout<<"no of policy sold\n";
cout<<pol_sold;
cout<<"your salary\n";
cout<<sal_a;
cout<<"category of the agent\n";
puts(cat_a);
}

}a;
void agent::nw_agt()
{int ch;
cout<<"please enter your details\n";
cout<<"enter your code\n";
cin>>code_a;

cout<<"enter your name\n";


gets(name_a);
cout<<"enter your age\n";
cin>>age_a;
cout<<"enter your area\n";
cin>>agt_add.area;
cout<<"enter your city\n";
cin>>agt_add.city;
cout<<"enter your state\n";
cin>>agt_add.state;
cout<<"no of policy sold\n";
cin>>pol_sold;
cout<<"enter your salary\n";
cin>>sal_a;
cout<<"category of the agent\n";
gets(cat_a);
cout<<"\n\ndo you want to save these details of the customer\n";
cin>>ch;
if(ch=='y')
{fstream f("agent_details.dat",ios::in|ios::binary);
while(!f.eof())
{f.write((char*)&a,sizeof(agent));
}
f.close();
}
else
exit(0);
}

void agent::ex_agt()
{int sea,fg=0;
cout<<"please enter your agent code\n";
cin>>sea;
fstream f("agent_details.dat",ios::in|ios::out|ios::binary);
while(!f.eof())
{f.read((char*)&a,sizeof(agent));
if(a.ret_agt_cod()==sea)
{
cout<<"match found\n";
a.show_det();
fg=1;
break;
}
else
{if(fg==0)
cout<<"not found\n";
}
f.close();
}
}
void main()
{clrscr();
int ch;
cout<<"who are you!!!! Are you a \n1.new agent\n2.existing agent\n";
cin>>ch;
if(ch==1)
{a.nw_agt();

}
else
{a.ex_agt();
}
getch();
}

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

#include<process.h>
#include<stdlib.h>
struct addr
{int hno;
char area[20];
char city[20];
char state[20];
};
class customer
{char name_c[20]; //name of the customer
int age_c;

//age of the customer

addr cust_add;

//address of the customer

char pol_bout[30]; //name of the policy bought


float sal_c;

//salary of the customer

int code_c;

//code of the customer

float pol_amt;

//amount of the policy

int pol_term;

//duration of policy bought if any

char mode_pay[10]; //mode of payment


float sa_pr_annum; //salary per annum
float premium;

//premium

int ch;
public:
void nw_cust();
void ex_cust();

//function fot the old customers

}c;
void customer::nw_cust()
{ cout<<"enter name\n";
cin>>name_c;

cout<<"enter your age\n";


cin>>age_c;
cout<<"enter your house no\n";
cin>>cust_add.hno;
cout<<"enter area\n";
cin>>cust_add.area;
cout<<"enter your city\n";
cin>>cust_add.city;
cout<<"enter your state\n";
cin>>cust_add.state;
cout<<"enter name of policies bought\n";
cin>>pol_bout;
cout<<"enter salary of the customer\n";
cin>>sal_c;
cout<<"enter code of the customer\n";
cin>>code_c;
cout<<"amount of the policy\n";
cin>>pol_amt;
cout<<"enter the duration of the policy\n";
cin>>pol_term;
cout<<"enter the mode of payment\n";
cin>>mode_pay;
cout<<"enter the salary per annum\n";
cin>>sa_pr_annum;
cout<<"enter the premium\n";
cin>>premium;
cout<<"\n\ndo you want to save these details of the customer\n";
cin>>ch;

if(ch=='y')
{fstream f("customer_details.dat",ios::in|ios::out|ios::binary);
while(!f.eof())
{f.write((char*)&c,sizeof(customer));
}
f.close();
}
else
exit(0);
}
void customer::ex_cust()
{int sea,ch;
cout<<"please enter your customer code\n";
cin>>sea;
fstream f("customer_details.dat",ios::in|ios::out|ios::binary);
while(!f.eof())
{f.read((char*)&c,sizeof(customer));
if(code_c==sea)
cout<<"match found\n";
}
f.close();
}

void main()
{clrscr();
int ch;
cout<<"who are you!!!! Are you a \n1.new customer\n2.existing customer\n";
cin>>ch;

if(ch==1)
{c.nw_cust();
}
else
{c.ex_cust();
}
getch();
}