Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Pratik Bakane C++
1. /*Program to declare class Account having data members as Account No.
and balance. Accept this data for 3 accounts and give interest of 10% where
balance is equal or greater than 5000 and display them*/
#include<iostream.h>
#include<conio.h>
class Account
{
public:
int acc_no,bal,inte;
void accept();
void display();
};
void Account::accept(void)
{
cout<<"tEnter the account number : ";
cin>>acc_no;
cout<<"tEnter the balance : ";
cin>>bal;
}
void Account::display(void)
{
2. cout<<"tThe account number is : "<<acc_no<<endl;
cout<<"tThe balance is : "<<bal<<endl;
}
void main()
{
int i;
clrscr();
Account a[3];
for(i=0;i<3;i++)
{
a[i].accept();
}
cout<<"*********************************************"<<endl;
for(i=0;i<3;i++)
{
if(a[i].bal>=5000)
{
a[i].inte=(a[i].bal*100)/10;
5. /*Program to declare a class city having data members as name and
population.Accept this data for 5 cities and display names of city
having highest population*/
#include<iostream.h>
#include<conio.h>
class city
{
public:
char name[20];
int population;
void accept()
{
cout<<"tEnter the Name of the city: ";
cin>>name;
cout<<"tEnter the population : ";
cin>>population;
}
void display()
{
cout<<"tName is : "<<name<<endl;
6. cout<<"tPopulation is : "<<population<<endl;
}
};
void main()
{
int i;
clrscr();
city c[5];
for(i=0;i<5;i++)
{
c[i].accept();
}
//sorting
for(i=0;i<5;i++)
{
for(int j=0;j<4;j++)
{
if(c[j].population<c[j+1].population)
{
city temp = c[j];
20. /*Program to implement multiple inheritance. Assume suitable
member variables and member functions(using virtual base class*/
#include<iostream.h>
#include<conio.h>
class acc
{
private:
char name[20];
public:
void accept1()
{
cout<<"nnttEnter the name : ";
cin>>name;
}
void display1()
{
cout<<"nnttThe name is : "<<name;
}
};
class sav_a:virtual public acc
21. {
private:
int no;
public:
void accept2()
{
cout<<"nnttEnter the number : ";
cin>>no;
}
void display2()
{
cout<<"nnttThe number is : "<<no;
}
};
class cur_a:public virtual acc
{
private:
int a_no;
public:
void accept3()
{
cout<<"nnttEnter the a_no number : ";
22. cin>>a_no;
}
void display3()
{
cout<<"nnttThe a_no is : "<<a_no;
}
};
class fix_dip:public sav_a,public cur_a
{
private:
int rec_no;
public:
void accept4()
{
cout<<"nnttEnter rec number : ";
cin>>rec_no;
}
void display4()
{
cout<<"nnttThe rec number is : "<<rec_no;
}
};
30. /*Program to declare a class book containing data members
book_title,author_name and price. Accept and display the
information for one object of the class using pointer to that
object.*/
#include<iostream.h>
#include<conio.h>
class book
{
int price;
char title[14],name[20];
public:
void getdata()
{
cout<<"nnttEnter the title of the Book : ";
cin>>title;
cout<<"nnttEnter the name of the Author :
";
cin>>name;
cout<<"nnttEnter the price of the Book : ";
cin>>price;
}
31. void putdata()
{
cout<<"nnttThe title of the Book is :
"<<title;
cout<<"nnttThe name of the Book is :
"<<name;
cout<<"nnttThe price of the Book is :
"<<price;
}
};
void main()
{
book b,*p;
clrscr();
p=&b;
p->getdata();
p->putdata();
getch();
}
33. /*Program to declare a class ‘box’ having data members
height,width and breadth.Accept this information for one
object using pointer to that object. Display the area and
volume of that object.*/
#include<iostream.h>
#include<conio.h>
class box
{
int height,width,breadth;
public:
void getdata()
{
cout<<"nnttEnter the height : ";
cin>>height;
cout<<"nnttEnter the width : ";
cin>>width;
cout<<"nnttEnter the breadth : ";
cin>>breadth;
}
void area()
{
34. cout<<"nnttArea of the box is :
"<<breadth*width;
}
void volume()
{
cout<<"nnttVolume of the Box is :
"<<height*width*breadth;
}
};
void main()
{
clrscr();
box b,*p;
p=&b;
p->getdata();
p->area();
p->volume();
getch();
}
36. /*program to declare a class birthday having data members day, month
and year. Accept this information for 4 object using pointer to the
array of object.*/
#include<iostream.h>
#include<conio.h>
class birthday
{
private:
int day,month,year;
public:
void getdata()
{
cout<<"ntEnter the Day : ";
cin>>day;
cout<<"ntEnter the Month : ";
cin>>month;
cout<<"ntEnter the Year : ";
cin>>year;
}
};
void main()
{