/*Pass By Value
Display the title of book having
minimum price
*/
#include<iostream>
using namespace std;
class Book
{
int price;
char title[20],author[20];
public:
void accept()
{
cout<<"\n\n Enter title, author and price of the book:";
cin>>title>>author>>price;
}
void display()
{
cout<<"\n\n Tittle: "<<title;
cout<<"\n Author: "<<author;
cout<<"\n Price: "<<price;
}
void max(Book b[]);
};
void Book::max(Book b[])
{
if(b[0].price < b[1].price)
b[0].display();
else if(b[1].price < b[0].price)
b[1].display();
else
{
cout<<"\n\n Same Price: ";
b[0].display();
b[1].display();
}
}
int main()
{
Book b[2];
b[0].accept();
b[1].accept();
cout<<"\n Max Price:";
b[0].max(b);
return 0;
}
Display the title of book having
minimum price
*/
#include<iostream>
using namespace std;
class Book
{
int price;
char title[20],author[20];
public:
void accept()
{
cout<<"\n\n Enter title, author and price of the book:";
cin>>title>>author>>price;
}
void display()
{
cout<<"\n\n Tittle: "<<title;
cout<<"\n Author: "<<author;
cout<<"\n Price: "<<price;
}
void max(Book b[]);
};
void Book::max(Book b[])
{
if(b[0].price < b[1].price)
b[0].display();
else if(b[1].price < b[0].price)
b[1].display();
else
{
cout<<"\n\n Same Price: ";
b[0].display();
b[1].display();
}
}
int main()
{
Book b[2];
b[0].accept();
b[1].accept();
cout<<"\n Max Price:";
b[0].max(b);
return 0;
}