Wednesday, 26 July 2017

program of class GST

#include<iostream.h>
#include<conio.h>
#include<STDIO.h>
class GST
{ public:
char name[20];
int nop,choice;
float dis,amount,gst,tprice;
void indata();
void outdata();
void cal();
float cal2();

};
void GST::indata()
{
cout<<"enter the name \n";
gets(name);
cout<<"enter the total number of people\n";
cin>>nop;
cout<<"enter the  price \n";
cin>>amount;
cal();
tprice=cal2();
}
void GST::outdata()
{
cout<<" name is ";
puts(name);
cout<<" total number of people ";
cout<<nop<<"\n";
cout<<" price  is";
cout<<amount<<"\n";
cout<<"discount is "<<dis<<"\n";
cout<<"gst is "<<gst<<"\n";
cout<<"total price "<<tprice<<"\n" ;
cout<<"THANK YOU FOR COMING \n";
}
void GST::cal()
{
int a=amount;
if(a<500)
{
dis=3;
gst=8;
}
else if((a>500)&&(a<1000))
{
dis=5;
gst=16;
}
else if((a>1000)&&(a<2500))
{
dis=8;
gst=28;
}
else if(a>2500)
{
dis=10;
gst=28;
}
else
{
cout<<" ";
}


}
float GST::cal2()
{
  int  a;
  int b;
  int c;
  a=(amount*(dis/100));
  b=(amount*(gst/100));
  c=amount+b-a;
  return c;
}
void main()
{
 clrscr();
int a;
cout<<"\t\tWELCOME  TO THE RESTURANT \n";
cout<<" do you want to get inside\n";
cout<<" if yes press 1 \n if not press 2\n";
cin>>a;
if(a==1)
{
GST g1;
g1.indata();
g1.outdata();
}
else if(a==2)
{
cout<<"THANK YOU COME NEXT TIME\n";
}
else
{
cout<<"wrong choice ";
}
getch();

}

program of class housing

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class housing
{
private:
long int reg_no[20];
char name[30];
char type;
float cost;

public:
void read_data();
void display();
void draw_nos();
};
void housing::read_data()
{
cout<<"enter the rejistration no \n";
cin>>reg_no;
cout<<"enter the name \n";
gets(name);
cout<<"enter the type \n";
cin>>type;
cout<<"enter the cost \n";
cin>>cost;
}

void housing::display()
{
cout<<"the rejistration no \n";
cout<<reg_no<<"\n";
cout<<"the name \n";
puts(name);
cout<<"the type \n";
cout<<type<<"\n";
cout<<"the cost \n";
cout<<cost<<"\n";
}
void main()
{
clrscr();
housing h1;
h1.read_data();
h1.display();
getch();
}

program of class addmision

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class add
{
private:
int ad_no;
char name[20];
float fees;

public:
void read_data();
void display();
void draw_nos();
};
void add::read_data()
{
for(int i=0;i<=2;i++)
{
cout<<"enter the name of student \n";
gets(name);
cout<<"enter the admission no \n";
cin>>ad_no;
cout<<"enter the fees  \n";
cin>>fees;
}
}
void add::display()
{
for(int i=0;i<=2;i++)
{
cout<<"the name of student is ";
puts(name);
cout<<" the admission no is ";
cout<<ad_no<<"\n";
cout<<" the fees is  ";
cout<<fees<<"\n";
}
}
void main()
{
clrscr();
add a1;
a1.read_data();
a1.display();
getch();
}

Thursday, 20 July 2017

program of class city

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class city
{
private:
int c_code;
char c_name;
long int nop;
float km;
float density;


public:
void record();
void view();
void manage();
};
void city::record()
{
cout<<"enter the code \n";
cin>>c_code;
cout<<"enter the name \n";
gets(c_name);
cout<<"enter the no of person\n";
cin>>nop;
cout<<"enter the km\n";
cin>>km;
density=(pop/km);
}

program of inheritance

#include<iostream.h>
#include<conio.h>
class a
{
int x;
protected:
int d;
int y;
};



class b
{      int a;
protected:
int b;
int f;

};
class c:public a,public b
{
int p;
public:
     int q;
     void getdata()
     {
cout<<"enter the value of x \n";
cin>>d;
cout<<"enter the value of y \n";
cin>>y;
     }

     void show()
     {
     cout<<d<<y;
     }
};
void main()
{
clrscr();
a obj1;
b obj2;
c obj3;
obj3.getdata();
obj3.show();
getch();
}

program of class of taxpayer

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class  taxpayer
{
private:
char name[10];
char  pan[20];
float inc;
float tax;
float comptax(float m);


public:
float  totax;
taxpayer(char n[10],float a);
void intax();
void outax();
};

float taxpayer::comptax(float m)
{

if(m<160000)
{
tax=0;
      // cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
else if((m>160000)&&(m<300000))
{
tax=5;
cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
else if((m>300000)&&(m<500000))
{
tax=10;
cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
else if(m>500000)
{
tax=15;
cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
return 0;
}


taxpayer::taxpayer(char n[10],float a)
{
cout<<"initially  \n ";
strcpy(name,n);
cout<<"\n";
strcpy(pan,"0");
cout<<"\n";
inc=a;
tax=0;
totax=0;
}

void taxpayer::intax()
{
cout<<"enter  your name\n";
gets(name);
cout<<"enter your pan  no\n";
cin>>pan;
cout<<"enter your salary\n";
cin>>inc;
totax=comptax(inc);
}
void taxpayer::outax()
{
cout<<" your name\t";
puts(name);
cout<<" your pan  no\t";
puts(pan);
cout<<"\n";
cout<<" your salary\t"<<inc<<"\n";
cout<<" tax is "<<totax<<"%\n";
}
void main()
{
clrscr();
taxpayer p1("arpit",0);
p1.outax();
p1.intax();
p1.outax();
getch();
}

program of CLASS OF hotel

#include<iostream.h>
#include<conio.h>
class hOTEL
{
private:
float rno;
char name[10];
float tariff;
int nod;
float calc()
{
float c;
c=nod*tariff;
if(c<10000)
{
return c;
}
else
{
return (c*1.05);
}
}
public:
void ci();
void co();
};
void h::ci()
{
cout<<"enter room no\n";
cin>>rno;
cout<<"enter your name\n";
cin>>name;
cout<<"enter the tarif\n";
cin>>tariff;
cout<<"enter the no of days\n";
cin>>nod;
}
void h::co()
{
int D;
cout<<"romm no is "<<rno<<"\n";
cout<<" name is "<<name<<"\n";
cout<<" tariif is"<<tariff<<"\n";
cout<<" number of days are "<<nod<<"\n";
D=calc();
cout<<" your total amount is "<<D<<"\n";
}
void main()
{
clrscr();
h h1;
h1.ci();
h1.co();
getch();
}

PROGRAM of INHERITANCE

#include<iostream.h>
#include<conio.h>
class base1
{
protected:
int sd1;
public:
base1()
{
sd1=100;
}
~base1()
{
}
int sample_funone()
{
return(sd1);
}
};
class base2
{
protected:
int sd2;
public:
base2()
{
sd2=200;
}
~base2()
{
}
int sample_funtwo()
{
return(sd2);
}
};
class D1:public base1,public base2
{
int mydata;
public:
D1()
{
mydata=300;
}
~D1()
{
}
int myfun()
{
return(mydata+sd1+sd2);
}
};
void main()
{clrscr();
base1 s1;
base2 s2;
D1 s3;
cout<<s3.base1::sample_funone();
cout<<s3.base2::sample_funtwo();
getch();
}

movie counter

#include<iostream.h>
#include<conio.h>
class M
{
public:
int c1,c2,t1,t2,i,x;
M();
void check();
void show();
};
M::M()
{
i=0;
t1=0;
c1=0;
c2=0;
}
void M::check()
{
cout<<"\t\t\twelcome to movie counter\n ";
cout<<"do you want to get ionside\n";
while(i<10)
{
cout<<"if you have ticket pres 1           for pass press 2\n";
cin>>x;
if(x==1)
{
cout<<"price is 250\n";
t1=t1+250;
c1++;
}
else if (x==2)
{
cout<<"you dont need ticket go inside\n";
cout<<"\t\t\t have fun\n";
c2++;
t2++;
}
else
{
cout<<"wrong option\n";

}
i++;
}
}
void M::show()
{
cout<<"total people\t"<<(c1+c2)<<"\n";
cout<<"total tickets\t"<<c1<<"\n";
cout<<"total pass\t"<<c2<<"\n";
cout<<"total income\t"<<t1<<"\n";
}
void main()
{
clrscr();
M m1;
m1.check();
m1.show();
getch();
}

destructor

#include<iostream.h>
#include<conio.h>
class test
{
int x;
float y;
public:
test(int a,int b)
{
cout<<"construtor\n";
x=a;
y=b;
cout<<x<<y<<"\n";

}
~test()
{
cout<<"object destroyed\n";
}
};
void main()
{
//clrscr();
test t1(10,20);
getch();
}

program of class using constructor and destructor

#include<iostream.h>
#include<conio.h>
class abc
{
int x;
float y;
public:
abc()
{
cout<<"construtor\n";
}
~abc()
{
cout<<"object destroyed\n";
}
};
void main()
{
clrscr();
abc x1;
getch();
}

class using constructor

#include<iostream.h>
#include<conio.h>
class A
{
public:
A()
{
cout<<"this is construtor\n";
}
~A()
{
cout<<"this is dest...\n";
}
};
void main()
{
clrscr();
A obj;
getch();
}

program of class of constructor

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class emp
{
public:
int emp_id;
int sal;
char name[20];
emp(int a,int b,char c[20])
{
emp_id=a;
sal=b;
strcpy(name,c);
cout<<"normal constructor\n"<<emp_id<<"\n"<<sal<<"\n"<<name<<"\n";
}
emp(emp&E)
{
emp_id=E.emp_id;
sal=E.sal;
strcpy(name,E.name);
cout<<"copy constructor\n"<<(2*emp_id)<<"\n"<<(2*sal)<<"\n"<<name;
}

};
void main()
{
clrscr();
int id,sal;
char ename[20];
cout<<"enter the id\n";
cin>>id;
cout<<"enter the sal\n";
cin>>sal;
cout<<"enter the name\n";
gets(ename);
emp E(id,sal,ename);
emp E1(E);
getch();
}

class using constructor

#include<iostream.h>
#include<conio.h>
class emp
{
public:
int emp_id;
int sal;
emp(int a,int b)
{
emp_id=a;
sal=b;
cout<<"normal constructor\n"<<emp_id<<"\n"<<sal<<"\n";
}
emp(emp&E)
{
emp_id=E.emp_id;
sal=E.sal;
cout<<"copy constructor\n"<<(2*emp_id)<<"\n"<<(2*sal);
}

};
void main()
{
clrscr();
int id,sal;
cout<<"enter the id\n";
cin>>id;
cout<<"enter the sal\n";
cin>>sal;
emp E(id,sal);
emp E1(E);
getch();
}

class of passing reference of another class

#include<iostream.h>
#include<conio.h>
class sample
{               public:
int i,j;
sample(int a,int b)
  {
i=a;
j=b;
 }
sample(sample&S)
{

j=S.j;
i=S.j;
cout<<"copy constructor\n"<<i<<"\n"<<j<<"\n";
}
void show()
{
cout<<"void show\n"<<j;
}
};
void main()
{
clrscr();
sample S(7,6);
sample s1(S);

S.show();
getch();
}

class to calculate marks of maths

#include<iostream.h>
#include<conio.h>
class A
{
public:
int a;
class B
{
public:
int b;
void show()
{
cout<<"2nd class\n";
cout<<"enter value of b \n";
cin>>b;
}
};
B bj;
void put()
{
cout<<"1st class\n";
cout<<"enter value of a \n";
void show();
}
}aj;
void main()
{
clrscr();
aj.put();
bj.show();
getch();
}#include<iostream.h>
#include<conio.h>
class maths
{
private:
int a[100];
int c;
public:
void input()
{
cout<<"enter the marks of math\n";
for(int j=0;j<=50;j++)
{
cin>>a[j];
}
bj.input(a);
}



class chem
{
private:
int sum[100];
int b[100];
int d[100];

public:
void input(int q[100])
    {
 for(int i=0;i<=50;i++)
 {
 d[i]=q[i];
 }

cout<<"enter marks of chem \n";
for(int i=0;i<=50;i++)
{
cin>>b[i];
sum[i]=d[i]+b[i];

}
for(int i=0;i<=50;i++)
{
cout<<sum[i];

}

cout<<"average\n"<<sum[]/2
    }

}bj;
}aj;
void main()
{
clrscr();
aj.input();
getch();
}

program of nesting class

#include<iostream.h>
#include<conio.h>
class A
{
public:
int a;
class B
{
public:
int b;
void show()
{
cout<<"2nd class\n";
cout<<"enter value of b \n";
cin>>b;
}
};
B bj;
void put()
{
cout<<"1st class\n";
cout<<"enter value of a \n";
void show();
}
}aj;
void main()
{
clrscr();
aj.put();
bj.show();
getch();
}

program of class and object

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class S
 {
private:
int adm_no;
int roll;
float mks;
char name[100];
float avg;
public:

void getdata()
{

cout<<"enter the name/n";
gets(name);
cout<<"enter roll no/n";
cin>>roll;
cout<<"enter adm no./n";
cin>>adm_no;
cout<<"enter cs marks/n";
cin>>mks;
}
void S::putdata()
{
cout<<" name\n";
puts(name);
cout<<" roll no\n";
cout<<roll;
cout<<" adm no\n";
cout<<adm_no;
cout<<" cs marks\n";
cout<<mks;
}
 void S::avg_marks(int n)
{
float sum=0;
for(int i=0;i<n;i++)
  {
sum=x[i]+sum;

  }
  float avg=sum/n;
  cout<<"average/n"<<avg;
}

 };

 void main()
 {
clrscr();
S x;
int i;
float r;
for(i=0;i<51;i++)
{
x[i].getdata();

}
for(i=0;i<51;i++)
{
x[i].putdata();
}
      x.avg_marks(51);
getch();
 }

Class to calculate the number and average of students

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class stu
 {
private:
int adm_no;
int roll;
float mks;
char name[100];
float avg;
int a;
public:
void getdata();
void putdata();
void c();
 };
void stu::getdata()
{

cout<<"enter the name/n";
gets(name);
cout<<"enter roll no/n";
cin>>roll;
cout<<"enter adm no./n";
cin>>adm_no;
cout<<"enter cs marks/n";
cin>>mks;
}
void stu::putdata()
{
cout<<" name\n";
puts(name);
cout<<" roll no\n";
cout<<roll;
cout<<" adm no\n";
cout<<adm_no;
cout<<" cs marks\n";
cout<<mks;
}
 void stu::c(int n)
{
a=n;
float sum=0;
for(int i=0;i<a;i++)
  {
sum=x[i]+sum;

  }
  float avg=sum/a;
  cout<<"average/n"<<avg;
}

 void main()
 {
clrscr();
stu x;
int i;
float r;
for(i=0;i<51;i++)
{
x[i].getdata();

}
for(i=0;i<51;i++)
{
x[i].putdata();
}
      x.c(51);
getch();
 }

program of class using scope resolution

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
class a
{
public:
char name[10];
int roll;
int age;
char city[50];
void takedata();
void showdata();
};
void a::takedata()
{
cout<<"enter name\n";
gets(name);
cout<<"enter roll\n";
cin>>roll;
cout<<"enter age\n";
cin>>age;
cout<<"enter city\n";
gets(city);
}
void a::showdata()
{
cout<<" name\n";
puts(name);
cout<<" roll\n";
cout<<roll<<"\n";
cout<<" age\n";
cout<<age<<"\n";
cout<<" city\n";
puts(city);
}
a obj;
obj.takedata();
obj.showdata();
getch();
}

program of class employ

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class emp
{
private:
int sal;
char ename[100];
char city[100];
int eid;
public:
void show();
void getdata();
};
public emp::void getdata()
{
cout<<"enter name  \n";
gets(ename);
cout<<"eneter id \n";
cin>>eid;
cout<<"enter city \n";
cin>>city;
cout<<"enter salary \n";
cin>>sal;
}
public emp::void showdata()
{   cout<<"enter name  \n";
puts(ename);
cout<<" id \n";
cout<<eid;
cout<<" city \n";
cout<<city;
cout<<" salary \n";
cout<<sal;
}
void main()
{
clrscr();
emp e1;
e1.getdata();
e1.showdata();
getch();
}

program of class play

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class play
{ public:
int playcode;
char title[100];
float dur;
int epi;
  void newplay()
  {
   cout<<"enter the play code\n";
   cin>>playcode;
   cout<<"enter the title\n";
   gets(title);
   }
  void moreinfo(float x,int y)
  {
  dur=x;
  epi=y;
  }
  void showplay()
  {
  cout<<"play code"<<playcode<<"\n";
  puts(title);
  cout<<"duration"<<dur<<"\n";
  cout<<"episode"<<epi<<"\n";
  }
};
void main()
{
clrscr();
int a,b;
cout<<"enter the duration\n";
cin>>a;
cout<<"enter the episode no\n";
cin>>b;
play p;
p.newplay();
p.moreinfo(a,b);
p.showplay();
getch();
}

program of class using multiple objcts

#include<iostream.h>
#include<conio.h>
class A
{  public:
int a;
int b;
int c;
A()
{
a=0;
b=0;
c=0;
}
A(int p,int q)
{
a=p;
b=q;
}
A(int f,int g,int h)
{
a=2*f;
b=2*g;
c=2*h;
}
void show()
      {
      cout<<"value of a\n"<<a;
      cout<<"value of b \n"<<b;
      cout<<"value of c \c"<<c;
      }
};

void main()
{
clrscr();
int a,b,c;
cout<<"enter the value of a , b, c\n";
cin>>a>>b>>c;
A a1;
A a2(a,b);
A a3(a,b,c);
a1.show();
a2.show();
a3.show();
getch();
}

class of factorial

#include<iostream.h>
#include<conio.h>
class factorial
{    public:
int n;
factorial(int a)
{
n=a;
}
void f()
  {
int f=1;
for(int i=1;i<=n;i++)
{
f=f*i;
}
cout<<f;
}
};
void main()
{
clrscr();
int n;
cout<<"enter the no";
cin>>n;
factorial obj(n);
obj.f();
getch();
}

wap of class to calculate sum

#include<iostream.h>
#include<conio.h>
class sum
{   public:
int a;
      sum(int b)
      {
      a=b;
      }
void s()
{
  int add=0;
  for(int i=1;i<=a;i++)
  {
add=add+i;
  }
  cout<<add;
}
};
void main()
{
clrscr();
int a;
cout<<"enter the no of terms\n";
cin>>a;
sum aj(a);
aj.s();
getch();
}

program of class to calculate area

#include<iostream.h>
#include<conio.h>
class area
{
public:
float r;
area(float a)
{
r=a;
}
void cal()
{
float a=3.14*r*r;
cout<<"area is"<<a;
}
};
void main()
{
clrscr();
float r;
cout<<"enter the value of radius\n";
cin>>r;
area A(r);
A.cal();
getch();
}