Cource File OOP LAB
Cource File OOP LAB
Jhanjeri, Mohali-140307
Department of Computer Applications
Sr.
Contents Yes/No
No.
1. Institute V/M; Department V/M/PEO; PO/PSO Statements
2. Academic Calendar
3. Lab Course Syllabus
4. Lab Course Data Sheet (with Complete details)
5. Lab Course Outcomes – Assessment Plan Sheet
6. Time Table of the Concerned Faculty Member
7. Detailed Lab Course Coverage
8. Lab Manuals
9. Quiz/Viva Sample Questions
10. Continuous Evaluation ( Lab Evaluation Sheets)
11. Sample Experiment Files (Two best , Two average & Two poor students)
12. Gaps & Plans for Add-on Experiments
13. Value Aided Experiments/Design Experiment/Open Ended Experiments
Any Innovative Method Adopted; Description
14.
(I.e. Projects/ charts/ PPTs/ Videos etc.)
15. Internal Awards Compilation Record (on Attached Performa)
Lab Course Outcomes Assessment (For NBA), Corrective Actions on CO
16.
Attainments
MISSION
● To provide quality education through state-of-art
infrastructure and well qualified faculty.
● Inculcating managerial skills and entrepreneurship in
students through strong industry interaction.
● Focus on specialized practical oriented teaching to
enhance the analytical skills for higher studies and best
employability.
● To imbibe ethical values and social responsibility among
students.
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
VISION
Provide research-based and world-class computer education
and training, and produce ethically sound and technically
competent versatile professionals.
MISSION
● To educate the students in the field of Computer-Science
with ever-changing technologies and skills.
● To enable the students in solving real-time problems and
make use of new technologies.
● To have industry collaboration and interaction with
professional societies for continuous development.
● To help students in becoming successful entrepreneurs.
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
PO1:Basic knowledge: An ability to apply knowledge of basic mathematics, science and domain
knowledge to solve the computational problems.
PO2. Discipline knowledge: An ability to apply discipline –specific knowledge to solve core
and/or applied computational problems.
PO3. Experiments and practice: An ability to plan and perform experiments and practices and
to use the results to solve computational problems.
PO4. Tools Usage: Apply appropriate technologies and tools with an understanding of
limitations.
PO5. Profession and society: Demonstrate knowledge to assess societal, health, safety, legal and
cultural issues and the consequent responsibilities relevant to professional practice.
PO6. Environment and sustainability: Understand the impact of the computational solutions in
societal and environmental contexts, and demonstrate the knowledge and need for sustainable
development.
PO7. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the professional practice.
PO8. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse/multidisciplinary teams.
PO10. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the context of technological changes..
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
Program: BCA L: 0 T: 0 P: 4
Branch: Computer Applications Credits: 2
Semester: 2nd Contact hours: 4 hours per week
Internal max. marks: 60 Theory/Practical: Practical
External max. marks: 40 Duration of end semester exam (ESE): 3hrs
Total marks: 100 Elective status: Core
1. Write a program to enter mark of 6 different subjects and find out the total mark
(Using
cin and cout statement)
2. Write a function using reference variables as arguments to swap the values of pair
of
integers.
3. Write a function to find largest of three numbers.
4. Write a program to find the factorial of a number.
5. Define a class to represent a bank account which includes the following members
as Data members:
a) Name of the depositor b) Account Number c) Withdrawal amount d) Balance
amount in the account
Member Functions:
a) To assign initial values b)To deposit an amount c) To withdraw an amount after
checking the balance d) To display name and balance.
6. Write the above program for handling n number of account holders using array of
objects.
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
7. Write a C++ program to compute area of right angle triangle, equilateral triangle,
isosceles triangle using function overloading concept.
8. Consider a publishing company that markets both book and audio cassette
version to its works. Create a class Publication that stores the title (a string) and
price (type float) of a publication. Derive the following two classes from the
above Publication class: Book which adds a page count (int) and Tape which
adds a playing time in minutes(float). Each class should have get_data() function
to get its data from the user at the keyboard. Write the main() function to test the
Book and Tape classes by creating instances of them asking the user to fill in
data with get_data() and then
displaying it using put_data().
9 Consider an example of declaring the examination result. Design three classes
. student, exam and result. The student has data members such as rollno, name.
Create the lass exam by inheriting the student class. The exam class adds data
members representing the marks scored in 5 subjects. Derive the result from
exam-class and it has own data
members like total, avg.
1 Write a program for overloading of Unary ++ operator.
0
.
1 Write a program for overloading of Binary + operator.
1
.
1 Write a program of Virtual Functions.
2
.
1 Write a program of Abstract Classes.
3
.
1 Write a program to read and write from file.
4
.
TEXT/REFERENCE BOOKS:
T/R BOOK TITLE/AUTHORS/PUBLICATION
1
Object Oriented Programming with C++, E. Balagurusami, Fourth Edition, Tata Mc-
Graw Hill.
2 Object Oriented Programming in Turbo C++, Robert Lafore, Fourth Edition Galgotia
Publications.
3 The C++ Programming Language, Bjarna Stroustrup, Third Edition, Addison-
Wesley Publishing Company.
4 Object Oriented Programming Using C++, Salaria, R. S, Fourth Edition, Khanna
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
Book Publishing
COURSE OUTCOMES:
SNo
DESCRIPTION PO(1..12) MAPPING
.
CO1 Design the classes. PO(1,2,3,4,5)
CO2 Illustrate the concept of memory representation for objects PO(1,2,3,4,5,8)
CO3 Implement programs using OOP concepts for various problems. PO(1,2,3,4,6)
CO4 Implement file handling in C++ PO(1,2,3,4)
CO5 Select the right data types to represent class properties. PO(1,2,3,4)
.COURSE OUTCOMES VS POS MAPPING (DETAILED; HIGH:3; MEDIUM:2; LOW:1):
SNO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10
Design the
CO1 3 2 3 3 3 - - - - -
classes.
Illustrate the
concept of
CO2 memory 3 2 3 2 1 - - 1 - -
representation for
objects
Implement
programs using
CO3 3 2 3 3 - 2 - - - -
OOP concepts for
various problems.
Implement file
CO4 2 2 3 2 - - - - - -
handling in C++
Select the right
data types to
CO5 2 2 3 3 - - - - - -
represent class
properties.
DELIVERY/INSTRUCTIONAL METHODOLOGIES:
✔ CHALK & TALK, PPT ✔ STUD. ✔ WEB RESOURCES ✔ NPTEL/OTHERS
ASSIGNMENT
✔ LCD/SMART ✔ STUD. SEMINARS ☐ ADD-ON COURSES ☐ WEBNIARS
BOARDS
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
ASSESSMENT METHODOLOGIES-DIRECT
✔ ASSIGNMENTS ✔ STUD. SEMINARS ✔ TESTS/MODEL ✔ UNIV.
EXAMS EXAMINATION
✔ STUD. LAB ☐ STUD. VIVA ☐ MINI/MAJOR ☐ CERTIFICATIONS
PRACTICES PROJECTS
☐ ADD-ON COURSES ☐ OTHERS
ASSESSMENT METHODOLOGIES-INDIRECT
✔ ASSESSMENT OF COURSE OUTCOMES (BY ✔ STUDENT FEEDBACK ON FACULTY
FEEDBACK, ONCE) (TWICE)
☐ ASSESSMENT OF MINI/MAJOR PROJECTS BY ☐ OTHERS
EXT. EXPERTS
COURSE PLAN
VISION:
Provide research-based and world-class computer education and training, and produce ethically
sound and technically competent versatile professionals.
MISSION:
● Develop the ability to adapt to technological skills to fulfill the challenges of the ever-
evolving global world.
● Induce knowledge that foster continuous improvement, self-learning, and innovation for
higher education.
● Students get to know about business software and help them to analyze the requirements
for developing systems.
● BCA graduates from CGC Jhanjeri will have the option to specialize in system software,
legacy application software or mobile applications.
Practical -1
1 Aim: Write a program to enter mark of 6 different subjects and find out the total mark
(Using cin and cout statement)
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include<iostream.h>
#include<conio.h>
int main() {
// To store the values of five subjects
float sub_1, sub_2, sub_3, sub_4, sub_5;
float total = 0.00;
cout << "Enter the marks of five subjects::\n";
cin >> sub_1 >> sub_2 >> sub_3 >> sub_4 >> sub_5;
// It will calculate the Total, Average and Percentage
total = sub_1 + sub_2 + sub_3 + sub_4 + sub_5;
// It will produce the final output
cout << "\nThe Total marks = " << total << "/500\n";
return 0;
}
Output
2 Aim: Write a function using reference variables as arguments to swap the values of pair of
integers.
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include<iostream.h>
#include<conio.h>
class abc
{
private:
int t;
public:
void swap(int *a, int *b)
{
t=*a;
*a=*b;
*b=t;
}
};
void main()
{
int a,b;
clrscr();
abc sa;
cout<<"Enter the values of A: ";
cin>>a;
cout<<"Enter the values of B: ";
cin>>b;
sa.swap(&a,&b);
cout<<"\nValue of A is: "<<a;
cout<<"\nValue of B is: "<<b;
getch();
}
OUTPUT
Enter the values of A:
20
Enter the values of B:
30
Value of A is 30
Value of B is 20
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
OUTPUT
Enter value for first number
56
Enter value for second number
96
Enter value for third number
75
Second number is greatest
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
5 Aim: Define a class to represent a bank account which includes the following members as
Data members:
a) Name of the depositor b) Account Number c) Withdrawal amount d) Balance
amount in the account
Member Functions:
b) To assign initial values b)To deposit an amount c) To withdraw an amount after
checking the balance d) To display name and balance.
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
class Bank
{
public:
char name[20];
int account_number;
int withdrawl_amount;
int balance;
void initialize()
{
cout<<"\nEnter Account Holders Name:";
gets(name);
cout<<"\nEnter account number:";
cin>>account_number;
cout<<"\Enter balance to deposit:";
cin>>balance;
}
void deposit()
{
int bal;
cout<<"\nEnter the amout to deposit:";
cin>>bal;
balance+=bal;
cout<<"\nAmount deposited successfuly\nYour New
Balance:"<<balance;
}
void withdrawl()
{
int withdrawl_amount;
cout<<"\nYour balance :"<<balance<<"\nEnter amount to withdraw:";
cin>> withdrawl_amount;
if(withdrawl_amount <=balance)
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
{
balance-= withdrawl_amount;
cout<<"\nRemaining Balance:"<<balance;
}
else
{
exit(0);
}
}
void display()
{
cout<<"\nName :";
puts(name);
cout<<"\nBalance :"<<balance;
}
};
void main()
{
int i;
clrscr();
Bank bk;
bk.initialize();
cout<<"\n1. Your Information\n2. Deposit\n3. Withdraw\nEnter your
choice\n";
cin>>i;
if(i==1)
{
bk.display();
}
else if(i==2)
{
bk.deposit();
}
else if(i==3)
{
bk.withdrawl();
}
getch();
}
OUTPUT
Enter Account Holders Name:
Baljeet
Enter account number:
1221
Enter balance to deposit:
12000
1. Your Information
2. Deposit
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
3. Withdraw
Enter your choice
2
Enter the amout to deposit:
1500
Amount deposited successfully
Your New Balance:13500
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
6 Aim: Write the above program for handling n number of account holders using array of
objects.
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
class Bank
{
public:
char name[20];
int account_number;
int withdrawl_amount;
int balance;
void initialize()
{
cout<<"\nEnter Account Holders Name:";
gets(name);
cout<<"\nEnter account number:";
cin>>account_number;
cout<<"\Enter balance to deposit:";
cin>>balance;
}
void deposit()
{
int bal;
cout<<"\nEnter the amout to deposit:";
cin>>bal;
balance+=bal;
cout<<"\nAmount deposited successfuly\nYour New
Balance:"<<balance;
}
void withdrawl()
{
int withdrawl_amount;
cout<<"\nYour balance :"<<balance<<"\nEnter amount to withdraw:";
cin>> withdrawl_amount;
if(withdrawl_amount <=balance)
{
balance-= withdrawl_amount;
cout<<"\nRemaining Balance:"<<balance;
}
else
{
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
exit(0);
}
}
void display()
{
cout<<"\nName :";
puts(name);
cout<<"\nBalance :"<<balance;
}
};
void main()
{
int i,j,n,accNum;
clrscr();
Bank bk[10];
cout<<"\ENTER NO OF ACCOUNT HOLDERS";
cin>>n;
for(j=0; j<n;j++)
{
bk[j].initialize();
}
cout<<"\n1. Your Information\n2. Deposit\n3. Withdraw\nEnter your
choice\n";
cin>>i;
cout<<"\n Enter account number to proceed\n";
cin>>accNum;
for(j=0; j<n;j++)
{
if(bk[j].account_number==accNum)
{
if(i==1)
{
bk[j].display();
}
else if(i==2)
{
bk[j].deposit();
}
else if(i==3)
{
bk[j].withdrawl();
}
}
}
getch();
}
OUTPUT
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
7 Aim: Write a C++ program to compute area of right angle triangle, equilateral triangle,
isosceles triangle using function overloading concept.
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include<iostream.h>
#include<math.h>
#include<conio.h>
class geometry
{
public:
float area(float side)
{
return(sqrt(3)*side*side/4);//area of equilateral triangle
}
float area(int a, int b)
{
return((b/2)*sqrt((a*a)-(b*b)/4));
}
float area(float base, float height)
{
return((base*height)/2);
}
};
int main()
{
geometry g;
float s,b,h;
int x, y;
int ch;
do
{
cout<<"\n\n *****Menu***** \n";
cout<<"\n 1. Area of right angled triangle";
cout<<"\n 2. Area of issoceless Triangle";
cout<<"\n 3. Area of equilateral triangle";
cout<<"\n 4. Exit";
cout<<"\n\n Enter Your Choice : ";
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"\n Enter the base: ";
cin>>b;
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
8 Aim: Consider a publishing company that markets both book and audio cassette version
to its works. Create a class Publication that stores the title (a string) and price (type
float) of a publication. Derive the following two classes from the above Publication
class: Book which adds a page count (int) and Tape which adds a playing time in
minutes(float). Each class should have get_data() function to get its data from the user
at the keyboard. Write the main() function to test the Book and Tape classes by
creating instances of them asking the user to fill in data with get_data() and then
displaying it using put_data().
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include <iostream.h>
#include <string.h>
#include <conio.h>
using namespace std;
class publication
{
private:
char title[30];
float price;
public:
void getdata(void)
{
cout << "Enter title of publication: ";
gets(title);
cout << "Enter price of publication: ";
cin >> price;
}
void putdata(void)
{
cout << "Publication title: " << title << endl;
cout << "Publication price: " << price<<endl;
}
};
class book :public publication
{
private:
int pagecount;
public:
void getdata(void)
{
publication::getdata(); //call publication class
function to get data
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
cout << "Enter Book Page Count: "; //Acquire book data
from user
cin >> pagecount;
}
void putdata(void)
{
publication::putdata(); //Show Publication data
cout << "Book page count: " << pagecount << endl; //Show
book data
}
};
class tape :public publication
{
private:
float ptime;
public:
void getdata(void)
{
publication::getdata();
cout << "Enter tap's playing time: ";
cin >> ptime;
}
void putdata(void)
{
publication::putdata();
cout << "Tap's playing time: " << ptime << endl;
}
};
void main(void)
{
book b;
tape t;
b.getdata();
t.getdata();
b.putdata();
t.putdata();
getch();
}
Output:
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
9 Aim: Consider an example of declaring the examination result. Design three classes
student, exam and result. The student has data members such as rollno, name. Create
the class exam by inheriting the student class. The exam class adds data members
representing the marks scored in 5 subjects. Derive the result from exam-class and it
has own data members like total, avg.
2. Software Used: Tool : Code blocks/ Turbo C++
Operating system : Windows 10 professional
Hardware : P-IV, RAM-2 GB , SSD 120
3. Source Code:
#include<iostream.h>
#include<string.h>
class Student
{
int roll_no;
char name[25];
public:
void ReadStudentData(void);
void DisplayStudentData(void); };
class Exam :public Student
{
protected:
int marks[6];
public :
void ReadExamMarks(void);
void DisplayExamMarks(void);
};
class Result : public Exam
{
int total_marks;
public : void Display(void);
};
void Student :: ReadStudentData()
{
cout<<" \n Enetr the Name:"<<endll;
cin>>name;
cout<< " \n Enter the Roll No.:"< <endll;
cin>>roll_no;
}
void Student :: DisplayStudentData()
{
cout<<" \n Name :"<<name<<endll;
cout <<" \n Roll No. :"<<roll_no <<endll;
}
void Exam::ReadExamMarks()
{
cout<<" \nEnter Marks :"<<endl;
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
3. Source Code:
#include<iostream.h>
#include<conio.h>
class complex
{
int a, b, c;
public:
complex()
{
}
void getvalue() {
cout << "Enter the Two Numbers:";
cin >> a>>b;
}
void operator++() {
a = ++a;
b = ++b;
}
void operator--() {
a = --a;
b = --b;
}
void display() {
cout << a << "+\t" << b << "i" << endl;
}
};
void main() {
clrscr();
complex obj;
obj.getvalue();
obj++;
cout << "Increment Complex Number\n";
obj.display();
obj--;
cout << "Decrement Complex Number\n";
obj.display();
getch();
}
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
OUTPUT
Enter the two numbers: 3 6
Increment Complex Number
4 + 7i
Decrement Complex Number
3 + 6i
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
getch();
}
OUTPUT:
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
void show()
{
cout << "show base class\n";
}
};
class derived : public base
{
public:
void print()
{
cout << "print derived class\n";
}
void show()
{
cout << "show derived class\n";
}
};
int main()
{
base *bptr;
derived d;
bptr = &d;
// Virtual function, binded at runtime
bptr->print();
// Non-virtual function, binded at compile time
bptr->show();
return 0;
}
OUTPUT:
print derived class
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
3. Source Code:
#include<iostream>
using namespace std;
class Base
{
int x;
public:
virtual void fun() = 0;
int getX() { return x; }
};
int main(void)
{
Derived d;
d.fun();
return 0;
}
Output:
fun() called
Chandigarh School of Business
Jhanjeri, Mohali-140307
Department of Computer Applications
3. Source Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream newfile;
newfile.open("tpoint.txt",ios::out); // open a file to perform write
operation using file object
if(newfile.is_open()) //checking whether the file is open {
newfile<<"Tutorials point \n"; //inserting text
newfile.close(); //close the file object
}
newfile.open("tpoint.txt",ios::in); //open a file to perform read
operation using file object
if (newfile.is_open()){ //checking whether the file is open
string tp;
while(getline(newfile, tp)){ //read data from file object and put it
into string.
cout << tp << "\n"; //print the data of the string
}
newfile.close(); //close the file object.
}
}
OUTPUT
Tutorials point