Professional Documents
Culture Documents
Task 1:: Create 10 Objects Array and Access The Index of 3,5,7,9 Ans
Task 1:: Create 10 Objects Array and Access The Index of 3,5,7,9 Ans
Objective(s):
Upon completion of this lab session, learners will be able to:
Array of Objects
Passing Objects as Arguments
Lab Tasks:
Task 1:
Create 10 objects array and access the index of 3,5,7,9
ANS:
#include <iostream>
int main(){
return 0;
}
%
Enrollment Number: ____________________________
Task 2:
Define a Class COPY with the following specifications:
Data Members:
copyNo
copyTitle
price
Member Functions:
take_data( ) A function to input copyNo,
copyTitle, price.
purchase_info( ) A function to ask the user to input the
number of copies to be
purchased of a copy. Then multiply it
with price of the copy.
[Note: User can search the copy using
its copyNo]
Write a menu driven program. Get data for five copy from user.
ANS:
#include<iostream>
using namespace std;
class Point
{
private:
int x, y;
public:
Point(int x1, int y1) { x = x1; y = y1; }
// Copy constructor
Point(const Point &p1) {x = p1.x; y = p1.y; }
int main()
{
Point p1(10, 15); // Normal constructor is called here
Page 2 of 4
%
Enrollment Number: ____________________________
return 0;
}
Task3:
Implement the given class diagram.
Empolyee
-id:int
-name:string
+setdata(int,string):void
+getdata(Employee t[]):void
Task 4:
Write a program with a class that contains following data
members
Id
name
marks
Create an array of objects of size 10. Create a function read()
to take input from user. Create a function to calculate
percentage of each student and a function that displays the id
and name of the student that have the lowest percentage.
s
1. 05
2. 2.5
3. 2.5
4. 05
Total 15 Signature
Note : Attempt all tasks and get them checked by your Lab Instructor.
Page 4 of 4