Prog C Experiment
Prog C Experiment
books that one being sold at the shop. He list Records of BOOK u want to store"<<endl;
includes details such as authors, title, price, cin>>n;
publisher and stock position. Whenever a for(int i=0;i<n;i++)
customer wants a book, the sales person {
input the title and author and the system cout<<"Enter The Details of Book
searches the list and displays whether it is "<<i+1<<endl;
available or not. If it is not, an appropriate cout<<"Enter Author"<<endl;
message is displayed. If it is then the system cin>>authors[i];
displays the book details and requests for the cout<<"Enter Title"<<endl;
number of copies required. cin>>title[i];
cout<<"Enter Price"<<endl;
#include<iostream.h> cin>>price[i];
#include<conio.h> cout<<"Enter Publisher"<<endl;
#include<string.h> cin>>publisher[i];
class Book cout<<"Enter Stock Available"<<endl;
{ cin>>stock[i];
char authors[10][20]; }
char title[10][20]; }
int price[10]; void Book::display()
char publisher[10][20]; {
int stock[10]; cout<<"\nRecord of Books in Store
int n; are:"<<endl;
public: for(int i=0;i<n;i++)
void input(); {
void display(); cout<<"Details of book: "<<i+1<<endl;
void search(); cout<<"Author: "<<authors[i]<<endl;
}; cout<<"Title: "<<title[i]<<endl;
void Book::input() cout<<"Price: "<<price[i]<<endl;
{ cout<<"Publisher: "<<publisher[i]<<endl;
cout<<"Stock Available: "<<stock[i]<<endl;
break;
}
}
if(t==0)
void Distance::showdist()
#include<iostream.h>
{
#include<conio.h>
cout<<"Distance in Feet:="<<feet<<"\t
class Distance
Inches:="<<inches<<"\n"<<endl;
{
}
int feet;
Distance Distance::operator +(Distance ob)
float inches;
{
public:
Distance d3;
void getdist();
d3.feet=feet+ob.feet;
void showdist();
d3.inches=inches+ob.inches;
Distance operator +(Distance ob);
if(d3.inches>=12)
Distance operator >(Distance ob);
{
};
d3.inches=d3.inches-12;
void Distance::getdist()
d3.feet=d3.feet+1;
{
}
cout<<"Enter Value of Feet"<<endl;
return d3;
cin>>feet;
}
cout<<"Enter Value of Inches:"<<endl;
{ d1.getdist(); d1.showdist();
a=feet*12+inches; d3=d1+d2;
if(a>b) d3.showdist();
{ d4=d1>d2;
d4.feet=ob.feet;
d4.inches=ob.inches;
return d4;
void main()
clrscr();
{
#include<iostream.h>
int rate;
#include<conio.h>
int hours;
class employee
public:
{
void get();
protected:
void display();
char name[20];
};
long int emp_no;
class salary_employee : public employee
public:
{
employee();
int bsalary;
~employee();
int allowance;
};
public:
void display(); {
}; cout<<"Enter Name:"<<endl;
cin>>rate; }
cin>>hours; {
} clrscr();
se.get();
se.display();
hourly_employee he;
he.get();
he.display();
getch();
void main()
{
clrscr();
Rectangle r1(5,10);
Square s1(6);
Triangle t1(2,4);
Dimension *ptr;
ptr=&r1;
float ar = ptr->area();
cout<<"Area of Rectangle:= "<<ar<<endl;
ptr=&s1;
ar = ptr->area();
cout<<"Area of Square:= "<<ar<<endl;
ptr=&t1;
ar = ptr->area();
cout<<"Area of Triangle:= "<<ar<<endl;
ob1.meters +=cm/100;
ob1.centimeters +=cm%100;
cout<<"After Addition
..."<<endl<<"Equivalent Distance in
Meter="<<ob1.meters<<endl;
cout<<"Centimeters="<<ob1.centimeters<<
endl;
}
void main()
{
clrscr();
DM ob1;
ob1.get_dist(4,10);
ob1.show_dist();
DB ob2;
ob2.get(7,9);
ob2.show();
add(ob1,ob2);
getch();
}
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main(int argc,char *argv[])
{
clrscr();
cout<<"first String from command line is:
"<<argv[1]<<endl;
cout<<"second String from command line
is: "<<argv[2]<<endl;
int c=strcmp(argv[1],argv[2]);
if(c==0)
cout<<"Both String from command line
argument are Equal";
else
cout<<"Both String from command line
argument are not Equal";
getch();
}