NBA - Boston Celtics

Thursday 10 October 2013

INHERITANCE


#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
const int len=25;
class employee
{
private:
char name[len];
unsigned long enumb;
public:
void getdata()
{
cout<<"enter name : ";gets(name);
cout<<"enter emlpoyee number : ";cin>>enumb;
}
void putdata()
{
cout<<"name : "<<name<<"\t";
cout<<"emp.number : "<<enumb<<"  ";
cout<<"basic salary : "<<basic;
}
protected:
float basic;
void getbasic()
{cout<<"enter basic : ";cin>>basic;}
};
class manager:private employee
{
private:
char title[len];
public:
void getdata()
{
employee::getdata();
getbasic();
cout<<"ener title : ";
gets(title);
cout<<"\n";
}
void putdata()
{
employee::putdata();
cout<<"\ttile : "<<title<<"\n";
}
};
void main()
{
manager m1,m2;
cout<<"manager1 :\n";
m1.getdata();
cout<<"manager2 :\n ";
m2.getdata();
cout<<"\t\tmanager 1 details : \n";
m1.putdata();
cout<<"\n\t\tmanager 2 details : \n";
m2.putdata();
}
OUTPUT


Wednesday 4 September 2013

linked list,stack and queue(1)

INSERTION  IN  A  LIST:


#include<iostream.h>
#include<process.h>
struct node
{
int info;
node*next;
}*save,*start,*newptr,*ptr;
node*create_new_node(int);
void insert_beg(node*);
void display(node*);
int main()
{
save=NULL;
int inf;
char ch;
ch='y';
while(ch=='Y'||ch=='y')
{
cout<<"enter information of new node : ";
cin>>inf;
newptr=create_new_node(inf);
insert_beg(newptr);
cout<<"now the list is : ";
display(start);
cout<<"want to enter nodes (y/n) : ";
cin>>ch;
}
return 0;
}
node*create_new_node(int n)
{
ptr=new node;
ptr->info=n;
ptr->next=NULL;
return ptr;
}
void insert_beg(node*np)
{
if(start==NULL)
start=np;
else
{
save=start;
start=np;
np->next=save;
}
}
void display(node*np)
{
while(np!=NULL)
{
cout<<np->info<<"->";
np=np->next;
}
cout<<"!!!\n";
}


OUTPUT


Monday 17 June 2013

HHW CTOR AND DTOR (4)


#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void amount(float princ,int time,float rate)
{
cout<<"\n principal amount : rs.::"<<princ;
cout<<"\ttime : "<<time<<"years";
cout<<"\t rate : "<<rate;
cout<<"\n interest amount : "<<(princ*rate*time)<<"\n";
}
void amount(float princ,int time)
{
cout<<"\n principal amount : rs."<<princ;
cout<<"\ttime : "<<time<<"years";
cout<<"\t rate : 0.08";
cout<<"\n interest amount : "<<(princ*0.08f*time)<<"\n";

}
void amount(float princ,float rate)
{
cout<<"\n principal amount : rs."<<princ;
cout<<"\ttime : "<<2<<"years";
cout<<"\t rate : "<<rate;
cout<<"\n interest amount : "<<(princ*rate*2)<<"\n";

}
void amount(int time,float rate)
{
cout<<"\n principal amount : rs."<<2000;
cout<<"\ttime : "<<time<<"years";
cout<<"\t rate : "<<rate;
cout<<"\n interest amount : "<<(2000*rate*time)<<"\n";

}
void amount(float princ)
{
cout<<"\n principal amount : rs."<<princ;
cout<<"\ttime : "<<2<<"years";
cout<<"\t rate : "<<0.08;
cout<<"\n interest amount : "<<(princ*0.08*2)<<"\n";

}
int main()
{
clrscr();
cout<<"case 1";
amount(2000.0f);
cout<<"case 2";
amount(2500.0f,3);
cout<<"case 3";
amount(2300.0f,3,0.11f);
cout<<"case 4";
amount(2000.0f,0.12f);
cout<<"case 5";
amount(6,0.07);
return 0;
}

HHW CTOR AND DTOR (3)


#include<iostream.h>
#include<stdlib.h>
void amount(float princ,int time =2,float rate =0.08);
void amount(float princ,int time,float rate)
{
cout<<"\nprincipal amount : rs."<<princ;
cout<<"\ttime:"<<time<<"years";
cout<<"\trate : "<<rate;
cout<<"\n interest amount : "<<(princ*rate*time)<<"\n";
}
int main()
{
cout<<"case 1 ";
amount(2000);
cout<<"case 2 ";
amount(2500,3);
cout<<"case 3 ";
amount(2300,3,0.11);
cout<<"case 4 ";
amount(2500,0.08);
return 0;
}


HHW CTOR AND DTOR (2)


#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class deposit
{
long int principal;
int time;
float rate;
float total_amt;
int r;
public:
deposit();
deposit(long p,int t,float f);
deposit(long p,int t);
deposit(long p,float r);
void calc_amt(void);
void display(void);
};
deposit :: deposit()
{
principal=time=rate=0.0;
}
deposit :: deposit(long p,int t,float r)
{
principal=p;time=t;rate=r;
}
deposit :: deposit(long p,int t)
{
principal=p;time=2;rate=r;
}
deposit :: deposit(long p,float r)
{
principal=p;time=2;rate=r;
}
void deposit :: calc_amt(void)
{
total_amt=principal+(principal*time*rate)/100;
}
void deposit :: display(void)
{
cout<<"\nprincipal amount : rs. "<<principal;
cout<<"\t\tperiod of investment : "<<time<<"years";;
cout<<"\nrate of intrest : "<<rate;
cout<<"\t\ttotal amount : rs. "<<total_amt<<"\n";
}
int main()
{
clrscr();
deposit d1,d2(200,2,0.07f),d3(4000,1),d4(3000,0.12f);
d1.calc_amt();
d2.calc_amt();
d3.calc_amt();
d4.calc_amt();
cout<<"object 1\n :";d1.display();
cout<<"object 2\n :";d2.display();
cout<<"object 3\n :";d3.display();
return 0;
}


HHW COTOR AND DTOR (1)


#include<conio.h>
#include<stdio.h>
#include<string.h>
class stud
{
int sno;
char sname[40];
public :
stud( )        // Default Constructor
{
sno=0;
strcpy(sname,"new");
cout<<"\nConstructing the object............";
}
~stud( )          // Destructor
{
cout<< "\nDestructing the object..............";
}
void getinfo( )
{
cout<<"\nEnter Student No. :";
cin>> sno;
cout<<"\nEnter Student Name :";
gets(sname);
}
void showinfo( )
{
cout<< "\n Student No.: "<<sno;
cout<<"\n Student Name :";
puts(sname);
}
};
void main()
{
clrscr();
stud obj;
obj.showinfo();
obj.getinfo();
obj.showinfo();
getch();
}

output


HHW CLASSE AND OBJECT (2)


#include<iostream.h>
class resort
{
int rno;
char name[20];
float charges;
int days;
float amount;
public:
void getinfo();
void compute();
void displayinfo();
};
void resort :: getinfo()
{
cout<<"enter room number :";
cin>>rno;
cout<<"enter your name :";
cin>>name;
cout<<"enter charge for 1 day : ";
cin>>charges;
cout<<"enter days : ";
cin>>days;
}
void resort :: displayinfo()
{
cout<<"\nyour room number : "<<rno;
cout<<"\nname : "<<name;
cout<<"\ncharges for 1 day : "<<charges;
cout<<"\ndays : "<<days;
if(amount>11000)
amount=1.02*charges*days;
amount=days*charges;
cout<<"\namount : "<<amount;
}
void main()
{
resort r;
r.getinfo();
r.displayinfo();
}
                                         
output


HHW. CLASSES AND OBJECT (1)


#include<iostream.h>
#include<conio.h>
int i;
class item
{
int itemcode[5];
float itemprice[5];
public:
void initials(void);
float largest(void);
float sum(void);
void display_items(void);
};
void item :: initials(void)
{
for(i=0;i<5;i++)
{
cout<<"enter item number "<<(i+1)<<" : ";
cout<<"\n enter itemcode : ";
cin>>itemcode[i];
cout<<"enter itemprice : ";
cin>>itemprice[i];
cout<<"\n";
}
}
float item :: largest(void)
{
float largest;
largest=itemprice[0];
for(i=0;i<5;i++)
if(largest<itemprice[i])
largest=itemprice[i];
return largest;
}
float item :: sum(void)
{
float sum=0;
for(i=0;i<5;i++)
{
sum+=itemprice[i];
}
return sum;
}
void item :: display_items(void)
{
for(i=0;i<5;i++)
{
cout<<"\nitem number "<<(i+1)<<" :";
cout<<"\n\titem code = "<<itemcode[i];
cout<<"\n\titem price = "<<itemprice[i];
cout<<"\n";
}
}
void main()
{
item order;
order.initials();
float total,biggest;
char ch=0;
clrscr();
do{
cout<<"item menu : ";
cout<<"\n1. largest price ";
cout<<"\n2. sum of prices";
cout<<"\n3. item list";
cout<<"choose 1-3 ? ";
cin>>ch;
switch(ch)
{
case '1':biggest=order.largest();
cout<<"largest price is "<<biggest;
break;
case '2':total=order.sum();
cout<<"sum of prices is "<<total;
break;
case '3':cout<<"item list is :\n";
order.display_items();
break;
default:cout<<"wrong choise...";
break;
}
}while(ch>=1 && ch<=3);
getch();
}

                                                                OUTPUT




Friday 14 December 2012

Pyramid


#include<iostream.h>
#include<conio.h>
void main()
{
int j=10;

for (int i=1;i<=10;i++)
{
for (int k=1;k<=j;k++)
{
cout<<" ";
}
for (int x=1;x<=i;x++)
{
cout<<"*";
cout<<" ";

}
cout<<"\n";
j--;
}
getch();
}

Sunday 18 November 2012

BIG-BIGGER-BIGGEST


#include<iostream.h>
#include<math.h>
void main()
{
int a,b,c,big1,big2,big3;
cout<<"enter the value of a,b and c : ";
cin>>a>>b>>c;
if(a>b)
{
if(a>c)
{
big1=a;
big2=c;
}
big3=b;
}
if(b>a)
{
if(b>c)
{
big1=b;
big2=c;
}
big3=a;
}
if(c>a)
{
if(c>b)
{
big1=c;
big2=b;
}
big3=a;
}
cout<<"the order are";
cout<<big1<<","<<big2<<","<<big3;
}

EVEN OR ODD OR PRIME



#include<iostream.h>
void main()
{
int num;
cout<<"enter any number : ";
cin>>num;
if(num==1)
{
cout<<"prime and neither even nor odd ";
}
else if(num==2)
cout<<"prime and even";
else
{
for(int i=2;i<=num/2;i++)
{
if(num%2==0)
cout<<"composite and even";
else
cout<<"composite and odd";
            break;

}

}
}

DIVISOR OF A NUMBER


#include<iostream.h>
void main()
{
  int num;
  cout<<"enter a number";
  cin>>num;
  for(int i=1;i<=num/2;i++)
{
if(num%i==0)
cout<<"\n"<<i;
}
}