If You Are From The 09 Batch Then Read This >>

This Site is created for the Bharati Vidyapeeth's BCA 09 Batch..and hence everyone from you are requested to send your email ID at abhilash238650@gmail.com..Owner will send you a request to your Email-ID and after accepting it even you can post your views, day to day experiences and class works on this blog.
Visit owner's blog at
www.bloggerabhilash.info

Wednesday, December 22, 2010

Program 21 to 24 !!!



21.write a programe for operator == for string

#include
#include
Class Prashant
{
char name[20];
int flag;
void getdata()
{
cout<<"Enter the Name";
cin>>name;
}
int operator==(prashant s)
{
flag=stremp(name,s.name);
return flag;
}
};
void main()
{
clrscr()
prashant s.t;
s.getdata();
t.getdata();
int x=(t==s);
y=(x==0)
cout<<"String are Equal";
else
cout<<"Not Equal";
getch();
}


22.Write a programe to demonstrate multiple hierasehical inheretense
a.accept deposit
b.display balance
c.compute & deposite interupt
4.permit withdrawl and update balance




#include
#include

Class account
{
public:
       char name[25];
       char type of[25];
       int amt,bal,withdraw,deposit;
     
account()
{
bal=500;
}
void getdata()
{
cout<<"Enter the name,a/c number and the type of ";
cin>>name>>accno>>typeof;
}
};
class current:public account
{
public:
void getdeposit()
{
cout<<"Enter the Deposit amt\n";
cin>>deposit;
bal=bal+deposit;
}
void withdrawamt()
{
cout<<"Enter the amt to withdraw\n";
cin>>withdraw;
}
void penalty()
}
if(bal<500)
bal=bal-50;
}
void display()
{
cout<<"Name\t"<<<<\n Accounttype\t",,typeof<<"\nBalance"<
}
};
class using:public account
{
float interest;
public;
void getdeposit()
{
cout<<"\nEnter the deposit amount\n";
cin>>deposit;
bal=bal+deposit;
}
void cal instrest()
{
int n=3;float r=7.5;
intrest=(bal*n*r)/100;
bal=bal+intrest;
}
void withdraw amt()
{
cout<<"Enter the amt to withdraw \n";
cin>>withdraw:
bal=bal-withdraw;
}
void penelty()
{
if(bal<500)
bal=bal-50;
}
void display()
{
cout<<"Name \t"<<<"\n Account \t"<<<"\naccount type\t"type of <<"\n balance "<<<
}
};
void main()
{
clrscr();
current a;
a.getdata();
a.getdeposit();
a.withdrawamt();
a.penalty();
a.display();

savingb;
b.getdeposit();
b.calintrest();
b.withdrawamt();
b.penalty();
getch();
}


23.write a program to demonstrate hybride inheramtence

#include
#include

Class student
{
public:
       char name[25];
int rollno;
void getdata()
{
cout<<"Enter the name & roll no of the student";
cin>>name>>rollno;
}
};
class test:public student
{
public:
int sem1,sem2;
void getmarks()
{
cout<<"\n Enter the marks of sem1 and sem2 \n";
cin>>sem1>>sem2;
}
};
class sports
{
public:
      int sportmarks;
voidgetscore()
{
cout<<"\n Enter the marks of sports \n;
cin>>sportsmarks;
}
};
class result:public  test.public sports
{
public:
int total;
void caltotal()
{
total=sem1+sem2+sportsmark;
}
void display()
{
cout<<"\n name1+"<<<"\nRoll no+"<<<"\ntotalmarks+"<
}
};
void main()
{
char();
resilts;
s.getdata();
s.getmarks();
s.getscore();
s.caltotal();
s.display();
getch();
}


24) WAP 2 model a database wth emp as a base class & wth the att name, id , for mgr att are titles & dues, writer attributes book labour att are wages.

    #include
    #include
   class employee
   {
   public:
   long id;
   char name[25];
   void get data()
   {
   cout<<"n\enter the name & id\n";
   cin>>name>>id;
    }
  };
   class manager:public employee
   {
   public :
   char title[30];
   long due;
   void get info ()
   {
   cout<<"\n enter the title & dues amt\n";
   cin>>title>>dues;
   }
   void display()
   {
   cout<<"\n Name\t"<<<"nid\t"<<<"\n
  title \t"<<<"\n dues\t"<
  }
};
class writer:public employee
{
public:
char books [25];
void get books()
{
cout <<"\nenter the name of  books\n";
cin>> books;
}
void display()
{
cout <<"\n Name \t"<<<"\nid\t"
<<<"\n book\t"<
  }
};
class labour :public employee
{
public:
int wages;
void get wages()
{
cout <<"enter the wages of the employee\n";
cin>>wages;
}
void display()
{
cout <<"enter the wages of the employee\n";
cin>>wages;
}
void display()
}
cout <<"\n Name \t"<<<"\nid\t"
<<<"\nwages\t"<
  }
};
void main()
{
clrscr();
manager s;
s.getdata();
s.getinfo();
s.display();
writer a;
a.getdata();
a.getbooks();
a.getdisplay();
labour b;
b.getdata();
b.getwages();
b.display();
getch();
}

Program 11 to 20 !!!

11. Create a class to calculate the marksheet with the attributes such as seat no, total marks, out of marks.

#include
#include

class result
{
long seatno;
int totalmarks;
int outofmarks;
void getdata();
void percentage();
void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a;
a.getdata();
a.percentage();
a.displaydata();
getch();
} tdio.h>
#include

class result
{
long seatno;
int totalmarks;
int outofmarks;
void getdata();
void percentage();
void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a;
a.getdata();
a.percentage();
a.displaydata();
getch();

}

 12. Create a class to calculate the marksheet with the attributes seat no, total marks, out of marks for 10 students.

#include
#include

class result
{
long seatno;
int totalmarks;
int outofmarks;
public:
    void getdata();
    void percentage();
    void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a[10];
for(i=1;i<=10;i++)
{
a[i].getdata();
a[i].percentage();
a[i].displaydata();
}
getch();
}  seatno;
int totalmarks;
int outofmarks;
public:
    void getdata();
    void percentage();
    void displaydata();
};

void result::getdata()
{
cout<<"Enter seatno,total marks,out of marks;
cin>>seatno>>totalmarks>>outofmarks;
}
void result::percentage()
{
percentage=(totalmarks)/(outofmarks)*100;
}
void result::display data()
{
cout<<"The percentage is<
}

void main()
{
result a[10];
for(i=1;i<=10;i++)
{
a[i].getdata();

a[i].percentage();
a[i].displaydata();
}
getch();
}

13. to calculate the total salary using gross salary=basic + 47%DA + 30% HRA with attribute a.getdata b.calculate salary and c. show details.

#include
#include

class salary
{
float basic,HRA,DA;
float grosssalary;
public:
    void getdata();
    void calsalary();
    void display();
};

void salary::getdata()
{
cout<<"Enter the basic salary \n";
cin>>basic;
DA=47/100*basic;
cout<<
HRA=30/100*basic;
cout<
}
void salary::calsalary()
{
grosssalary=(basic+HRA=DA);
}
void salary::display()
{
cout<<
}

void main()
{
clrscr();
salary s;
s.getdata();
s.calsalary();
s.display(); 
getch();
}
#include

class salary
{
float basic,HRA,DA;
float grosssalary;
public:
    void getdata();
    void calsalary();
    void display();
};

void salary::getdata()
{
cout<<"Enter the basic salary \n";
cin>>basic;
DA=47/100*basic;
cout<<
HRA=30/100*basic;
cout<
}
void salary::calsalary()
{
grosssalary=(basic+HRA=DA);
}
void salary::display()
{
cout<<
}

void main()
{
clrscr();
salary s;
s.getdata();
s.calsalary();
s.display();

getch();
}


14. using switch statement. Create account class for following operators. 1. create account, 2.deposit, 3.withdraw. 4.bal enquiry 5.show details.

#include
#include
#include

class account
{
private:
    long int actno;
    char name[40];
    float bal;
public:
account()
{
bal=500.00;
}
void createaccount()
{
cout<<" \n Enter ACT NO AND NAME \n";
cin>>actno>>name;
cout<<"\n Account is created sucessfully \n";
}
void deposit()
{
int deposit;
cout<<" \ n Enter Amt to Deposit \n";
Cin>>deposit;
bal=bal+deposit;
}
void withdraw()
{
int wd;
cout<<" \n Enter Amt to withdraw \n";
cin>>wd;
if(bal <= 500)
  cout<<" \n Sorry! insufficient Amt \n";
else if(wd>=bal)
  cout<<" \n Sorry! insufficient Amt \n";
else
  bal=bal-wd;
}
void showdetails()
{
cout<<" \n--------------------Welcome to SBI----------------\n";
cout<<" \n A/c no.<
cout<<" \n Name"<
cout<<" \n Balance"<
cout<<" \n---------------------SBI--------------------------\n";
}
};
void main()
{
clrscr();
account a;

int op;
do{
cout<<"\n---------------------------------------------------\n";
cout<<"\n OPTION 1:- create A/c  \n";
cout<<"\n OPTION 2:- Deposit     \n";
cout<<"\n OPTION 3:- Withdrawn   \n";
cout<<"\n OPTION 4:- Bal Enquiry \n";
cout<<"\n OPTION 5:- EXIT        \n";
cout<<"\n Enter your choice      \n";
cout<<"\n---------------------------------------------------\n";
cin>>op;
switch(op)
{
case1:a.create account();break;
case2:a.deposit();break;
case3:a.withdraw();break;
case4:a.showdetails();break;
case5:exit(0);
default:cout<<"Sorry!Invalid choice";
}
}
while(op!=5);
getch();
}


15. using switch statement. create a/c class for following operators for 10 persons - create a/c, deposit, withdraw, bal enquiry, show details.

#include
#include
#include

class account
{
private:
    long int actno;
    char name[40];
    float bal;
public:
account()
{
bal=500.00;
}
void createaccount()
{
cout<<" \n Enter ACT NO AND NAME \n";
cin>>actno>>name;
cout<<"\n Account is created sucessfully \n";
}
void deposit()
{
int deposit;
cout<<" \ n Enter Amt to Deposit \n";
Cin>>deposit;
bal=bal+deposit;
}
void withdraw()
{
int wd;
cout<<" \n Enter Amt to withdraw \n";
cin>>wd;
if(bal <= 500)
  cout<<" \n Sorry! insufficient Amt \n";
else if(wd>=bal)
  cout<<" \n Sorry! insufficient Amt \n";
else
  bal=bal-wd;
}
void showdetails()
{
cout<<" \n--------------------Welcome to SBI----------------\n";
cout<<" \n A/c no.<
cout<<" \n Name"<
cout<<" \n Balance"<
cout<<" \n---------------------SBI--------------------------\n";
}
};
void main()
{
clrscr();
account a[i];

int op;
for(i=1;i<=10,i++)
{
do
{
cout<<"\n---------------------------------------------------\n";
cout<<"\n OPTION 1:- create A/c  \n";
cout<<"\n OPTION 2:- Deposit     \n";
cout<<"\n OPTION 3:- Withdrawn   \n";
cout<<"\n OPTION 4:- Bal Enquiry \n";
cout<<"\n OPTION 5:- EXIT        \n";
cout<<"\n Enter your choice      \n";
cout<<"\n---------------------------------------------------\n";
cin>>op;
switch(op)
{
case1:a[i].create account();break;
case2:a[i].deposit();break;
case3:a[i].withdraw();break;
case4:a[i].showdetails();break;
case5:exit(0);
default:cout<<"Sorry!Invalid choice";
}
}
while(op!=5);
}
getch();
} ";
cout<<"\n OPTION 2:- Deposit     \n";
cout<<"\n OPTION 3:- Withdrawn   \n";
cout<<"\n OPTION 4:- Bal Enquiry \n";
cout<<"\n OPTION 5:- EXIT        \n";
cout<<"\n Enter your choice      \n";
cout<<"\n---------------------------------------------------\n";
cin>>op;
switch(op)
{
case1:a[i].create account();break;
case2:a[i].deposit();break;
case3:a[i].withdraw();break;
case4:a[i].showdetails();break;
case5:exit(0);
default:cout<<"Sorry!Invalid choice";

}
}
while(op!=5);
getch();
}


16. to calculate area of rectangle using DEFAULT CONSTRUCTION.

a] Default constructor

#include
#include
class rectangle
{
int l,b;
float area;
public:
void rectangle()
{
l=10;
b=20;
}
void calculate()
{
area=l*b;
}
void show()
{
cout<<"area= "<
}
};
void main()
{
clrscr();
rectangle r;
r.getdata();
r.calculate();
r.show();
getch();
}

b] PARAMETERIZED Constructor

#include
#include
class rectangle
{
int l,b;
float A;
public:
rectangle(int p,int q)
{
l=p;
b=q;
}
void call()
{
a=l*b;
}
void display()
{
cout<<"\n Length & Breadth is "<<
cout<<"\n Area is "<<;
}
};
void main()
{
clrscr();
rectangle r(10,20);
r.cal();
r.display();
getch();
}


17th- Unary operator for increament

#include
#include
class unary
{
int x,y,z;
public:
void getdata();
void operator+();
void show();
};
void unary::getdata(int a,int b,int c)
{
x=a;
y=b;
z=c;
}
void unary::show
{
cout<<<
}
void main()
{
clrscr();
unary s;
s.getdata(2,3,4);
+s;
s.show();
getch();
}


18- Binary to overload + operator

#include
#include
class binary
{
float a,b;
public:
binary(float x,float y)
{
a=x;
b=y;
}
binary operator +(binary)
};
binary operator +(binary b)
{
binary p;
p.a=a+b/a;
p.b=b+b/b;
return(p);
}
void main()
{
binary c1,c2;
c1(1.2,2.3);
c2(2.0,2.1);
c3=c1+c2;
c3.show();
getch();
}


19- using(18) friend function

#include
#include
class binary
{
float a,b;
public:
binary(float x,float y)
{
a=x;
b=y;
}
void friend operator+(binary);
};
void friend operator+(binary);
{
binary p;
p.a=a+b1.a;
p.b=b+b1.b;
return(p);
}
void main()
{
binary c1,c2;
c1(1.2,2.3);
c2(2.0,2.1);
c3=c1+c2;
c3.show();
getch();
}


20 - for + operator for string

#include
#include
#include
class string
{
char *p;
int n;
public:
string(){n=0;p=0;}
string(const char *s);
string(const string &s);
friend string operator +(const string & s.cout string &t);
friend void show(const string s);
};
string::string(const char*s)
{
n=strlen(s);
p=new data[n+1];
strcpy(p,s);
}
string::string(const string &s)
{
n=s.n;
p=new char[n+1];
strcpy(p,s.p);
}
string operator+(const string &s, const string &t)
{
string temp;
temp.n=s.n+t.n;
temp.p=new char[temp.n+1];
strcpy(temp.p,s.p);
strcat(temp.p,t.p);
return(temp);
}
void show(const string s)
{
cout<
}
void main()
{
show(s1)="Bharati";
show(s2)="Vidyapeeth";
show(t3);
getch();
}

Program 1 to 10 !!!

 1. swap 2 numbers using call by value.

#include
#include

void swap (int a,int b)
{
int t;
t=a;
a=b;
b=t;

cout<<
}

void main()
{
clrscr();
void swap(int a,int b);
int x,y;
x=10;
y=15;
swap(x,y);
getch();
}



2. swap two numbers using call by reference.


#include
#include

void swap (int *a,int *b)
{
int t;
t=&a;
&a=&b;
&b=t;
}


void main()
{
clrscr();
void swap(int *a,int *b);
int x,y;
x=10;
y=15;
swap(&x,&y);
cout<<"Swapped values are"<<
getch();
}



3.inline function to calculate Area of CIRCLE 

#include
#include

inline float area(int r)
{
return(3.14*r*r);
}

void main()
{
clrscr();
int r=5;
float b;
b=area(r);
cout<
getch();


3.b. inline function for avg of 3 nos.

#include
#include

inline float avg(int a,int b,int c)
{
return((a+b+c)/3);
}

void main()
int a,b,c;
clrscr();
cout<<"Enter the nos.";
cin>>a>>b>>c;
float av=avg(a,b,c);
cout<
getch();
}


3.c. inline function for area of triangle

#include
#include

inline float area(int b,int h)
{
return(0.5*b*h);
}

void main()
{
int b,h;
clrscr();
cout<<"Enter the height and base of triangle";
cin>>b>>h;
float ar=area(b,h);
cout<
getch();
}


4. overload a function to add integer, float and double each having 2 or 3 parameters.

#include
#include

int add(int a,int b);
float add(float a,float b,float c);
double add(double x,double y);

int add(int a,int b)
{
return(a+b);
}
float add(float a,float b,float c)
{
return(a+b+c);
}
double add(double x,double y)
{
return(X+y);
}

void main()
{
clrscr();
cout<<
cout<<
cout<<
getch();
}


5. overload a function to calculate area of rectangle having different data types such as integer,float and double.

 #include
#include

int area(int l,int b);
float area(float l,float b);
double(double l,double b);

int area(int l,int b)
{
return(l*b);
}
float area(float l,float b)
{
return(l*b);
}
double area(double l,double b)
{
return(l*b);
}

void main()
{
int l,b;
clrscr();
cout<<
cout<<
cout<<
getch();
}



6. To calculate area of triangle ,rectangle and square. 


#include
#include

float triangle(float b,float h);
float rectangle(float l,float b);
float square(float s);

float triangle(float b,float h)
{
return(0.5*b*h);
}
float rectangle(float l,flaot b)
{
return(l*b);
}
float square(float s)
{
return(4*s);
}

void main()
int l,b,h,s;
clrscr();
cout<<
cout<<
cout<<
getch();



7. To find the interest with rate 1.5 using default argument 


#include
#include

float interest(int p,int n,float r=1.5)
{
return((p*n*r)/100);
}

void main()
{
clrscr();
int p,n;
cout<<"Enter principle and no.years \n";
cin>>p>>n;
float i=interest(p,n);
cout<<"interest is"<
getch();



8. to give alias name to a variable principle in calculating simple interest & then modifying the variable. 


#include
#include

float interest(int p,int n,float r)
{
return((p*n*r)/100);
}

void main()
{
clrscr();
int p,n;
int &alias=p;
float r;
cout<<"Enter the principles & no. of years \n";
cin>>p>>n>>r;
float i=interest(p,n,r);
cout<<"\n interest is before modifying \t"<
alias=20;
cout<<"\n principle is modified \t"<i=interest(p,n,r);
cout<<"\n Interest after modifying principle \t"<
getch();
}



9. Swap the 2 numbers using reference variable.


#include
#include

void swap(int &a,int &b)
{
int t;
t=a;
a=b;
b=t;
}

void main()
{
void swap(int &a,int &b);
clrscr();
int x=10;
int y=20;
cout<<"before swapping \t"<<<"   \t"<
swap(x,y);
cout<<"  \n after swapping   \t"<<<    \t"<
getch();
}



10. to take student's information from the user & display it using CLASS student. 


#include
#include

class stud
{
int rno;
char name[20];
public:
void getdata()
{
cout<<"Enter the roll no. &name \n";
cin>>rno>>name;
}
void display()
{
cout<<"\n Roll no \t"<<<" \n Nmae  \t"<
}
};

void main()
{
clrscr();
stud s;
s.getdata();
s.display();
getch();
}

Tuesday, December 14, 2010



SAQUIB
Wish You Many Many Happy Return's Of The Day

Tuesday, December 7, 2010

BCA SEM-3 Exam Begins !!!

            The exams of Third Semester begins today. Best of luck to everyone. Hope all of us do our best in this exam. This is known to everyone that this semester is the toughest Semester and the very first exam CAOS is itself the toughest one. Lets hope to achieve the best. Hope all our classmates who are struggling with back subjects comes out of that disaster and no one gets a KT in this semester.

           Thanks.

Just Type The Keyword To Search Your Answer -- >>