//PROGRAM
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
//class
class travelplan
{long plancode;
char place[10];
int noofpeople;
int noofbus;
public:
travelplan();
void newplan();
void showplan();
}travel;
void travelplan::travelplan()
{cout<<"enter the plancode"<<endl;
cin>>plancode;
cout<<endl;
cout<<"enter the place"<<endl;
gets(place);
cout<<endl;
cout<<"enter the no of travellers"<<endl;
cin>>noofpeople;
cout<<endl;
}
void travelplan::newplan()
{if(noofpeople<20)
{noofbus=1;}
else if((noofpeople>=20)&&(noofpeople<40))
{noofbus=2;}
else if(noofpeople>=40)
{noofbus=3;}
}
void travelplan::showplan()
{cout<<"Plan code : "<<plancode<<endl;
cout<<"Place : ";
puts(place);
cout<<endl;
cout<<"No of travellers : "<<noofpeople<<endl;
cout<<"No of bus : "<<noofbus<<endl;
}
void main()
{travel.newplan();
travel.showplan();
getch();
}
Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]
Showing posts with label Class. Show all posts
Showing posts with label Class. Show all posts
Travel Plan ( Classes )
Click Here To Download C++ File Of This Program
Publications ( Classes )
Click Here To Download C++ File Of This Program
//Prg to keep record of books & Audio Cassetes
//Downloaded From www.c4cpp.co.nr
//(C)2009.All rights reserved.
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<stdio.h>
class publication
{
char title[20];
float price;
public:
void getdata()
{
cout<<"Enter Title"<<endl;
gets(title);
cout<<"Enter Price"<<endl;
cin>>price;
}
void putdata()
{
cout<<"Title"<<endl;
puts(title);
cout<<"Price"<<endl;
cout<<price;
}};
class book : protected publication
{
int pagecount;
public:
void putdata()
{
publication :: putdata();
cout<<endl<<"Pg Count"<<endl;
cout<<pagecount;
}
void getdata()
{
publication::getdata();
cout<<"Pg Count"<<endl;
cin>>pagecount;
}
};
class tape : protected publication
{
float time;
public:
void getdata()
{
publication :: getdata();
cout<<"Enter Time"<<endl;
cin>>time;
}
void putdata()
{
publication :: putdata();
cout<<endl<<"Time "<<endl;
cout<<time;
}
};
void main()
{
clrscr();
book b;
tape t;
int ch;
x:
{
cout<<endl<<"1. BOOK 2:Tape 3:Exit "<<endl;
cin>>ch;
switch(ch)
{
case 1:b.getdata();
b.putdata();
goto x;
case 2:t.getdata();
t.putdata();
goto x;
case 3:exit(0);
}
}
getch();
}
Merge two Arrays
Click Here To Download C++ File Of This Program
//prg to merge arrays
//Downloaded From www.c4cpp.co.nr
//(C)2009.All rights reserved.
#include<iostream.h>
#include<conio.h>
int c[100],i,j,k;
class merged
{
int na,nb,a[50],b[50];
public:
void merge();
void display();
void input();
}g;
void merged::merge()
{
int j=0;
int i=na-1;
while((i>0)&&(j<nb))
{
if (b[j]<a[i])
{
c[k]=a[i];
i--;
k++;
}
if (b[j]>a[i])
{
c[k]=b[j];
j++;
k++;
}
if (b[j]==a[i])
{
c[k]=b[j];
j++;
k++;
c[k]=a[i];
i--;
k++;
}
}
if(i==-1)
{
while(j<nb)
{
c[k]=b[j];
j++;
k++;
}
}
if(j==nb)
{
while(i>=0)
{
c[k]=a[i];
i--;
k++;
}
}
}
void merged::display()
{
for(i=0;i<na+nb;i++)
cout<<c[i];
}
void merged::input()
{
cout<<"Enter A Lim"<<endl;
cin>>na;
cout<<"Enter B Limit"<<endl;
cin>>nb;
cout<<"Enter array A"<<endl;
for(i=0;i<na;i++)
cin>>a[i];
cout<<"Enter Array B"<<endl;
for(j=0;j<nb;j++)
cin>>b[j];
}
void main()
{
clrscr();
g.input();
g.merge();
g.display();
getch();
}
Classes & Objects
Classes & Objects
Program By - Karun J
Click Here To Download C++ File Of This Program
Click Here To Download Word File ( with output )
Inserting Objects
Program By - Karun J
Click Here To Download C++ File Of This Program
Click Here To Download Word File ( with output )
Program By - Karun J
Click Here To Download C++ File Of This Program
Click Here To Download Word File ( with output )
Inserting Objects
Program By - Karun J
Click Here To Download C++ File Of This Program
Click Here To Download Word File ( with output )
Subscribe to:
Posts (Atom)