Академический Документы
Профессиональный Документы
Культура Документы
2
PART B
(PART B: TO BE COMPLETED BY STUDENTS)
(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned
lab in charge faculties at the end of the practical in case the there is no Black board access
available)
Roll No.H043
Name:Rushin Shah
Program:Btech
Division:H
Semester:2nd
Batch :H3
Date of Experiment: 18/1/16
Date of Submission: 1/2/16
Grade :
{
convt m;
clrscr();
m.input();
m.convt();
m.display();
getch();
}
P2. Modify P1 (practical 2); add a class DB to store distance in feet and inches (Data
Members) and below member functions:
1. Convert For converting feet into inches
2. Display- For displaying data of objects
ANS.
#include<iostream.h>
#include<conio.h>
class db
{
float feet, inches;
public:
void input()
{
cout<< enter the value in feet:;
cin>>feet;
}
void convert()
{
inches=feet/12;
}
void display()
{
cout<< \n the value in inches is:<<inches;
}
friend void add();
};
class dm
{
int m, cm;
public:
void convert()
{
cout<< value in metre:;
cin>>metre;
cm=m*100;
}
void display()
{
cout<< value in cm:;
cout<<cm;
}
};
void main()
{
clrscr();
db d;
dm a;
a.convert();
a.display();
d.input();
d.convert();
d.display(); getch();
}
P3. Modify P2 (practical 2); Write a program that can read values for the class objects and add
one object of DM with another object of DB. Use friend function to carry out the addition
operation.
ANS:
#include<iostream.h>
#include<conio.h>
class dm;
class db
{
float feet, inches;
public:
void input()
{
cout<< enter value in feet:<<`\n`;
cin>>feet;
}
void convert()
{
inches=feet/12;
}
void display()
{
cout<< value in inches:<<inches;
}
friend void add(db, dm);
};
class dm
{
int m,cm;
public:
void convert() {
cout<< value in metre:<<`\n`;
cin>>m;
cm=m*100;
}
void display()
{
cout<< value in cm:<< `\n`;
cout<<cm;
}
friend void add(dm, db);
};
void add(dm a, db d)
{
int c;
c = a.cm + b.inches;
cout<< sum is<<c;
}
void main()
{
clrscr();
db d;
dm a;
a.convert();
a.display();
d.input();
d.convert();
d.display();
sum(e, b)
getch();
}
B.3 Conclusion:
(Students must write the conclusion as per the attainment of individual outcome listed above
and learning/observation noted in section B.1)