Compare commits

...

9 Commits

Author SHA1 Message Date
d62e8dd839 use the titlepage prescribed by the uni
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2023-01-03 13:32:59 +05:30
a903457fa4 lab9: reflect changes for 26 in file.org
and change typename keyword to class for convention and fix indentation

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-27 13:43:39 +05:30
10350a5670 Merge pull request 'fixed errors' (#1) from eternal-will/ooplab:master into master
Reviewed-on: #1
2022-12-27 08:08:04 +00:00
922c90afc1 fixed errors 2022-12-27 05:09:23 +00:00
9e7cffdc32 lab 10: init
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-26 18:38:55 +05:30
42902fa122 labs 9: init
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-26 18:06:44 +05:30
4824ab9855 labs 8: init
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-26 17:30:37 +05:30
7ba9554ed5 labs 7: init
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-26 16:53:39 +05:30
21afaa311b fix minor latex issues
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-26 16:30:38 +05:30
27 changed files with 957 additions and 42 deletions

3
.gitignore vendored
View File

@@ -4,3 +4,6 @@
_minted-file/
.\#
*html
lab*/*pdf
*.in
*.out

View File

@@ -1,12 +1,21 @@
#+title: Object Orientated Programming Lab
#+author: Amneesh Singh I6
#+LATEX_CLASS_OPTIONS: [a4paper,12pt]
#+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}
#+LATEX_HEADER: \usepackage{fontspec}
#+LATEX_HAEDER: \usepackage{graphicx}
#+LATEX_HAEDER: \usepackage{longtable}
#+LATEX_HEADER: \setmainfont{LiberationSerif}
#+LATEX_HEADER: \date{}
#+OPTIONS: toc:nil ^:nil
#+INCLUDE: front.tex
#+LATEX: \clearpage
|----------------------------------------------------------------|
| Programs are followed by their respective outputs (and inputs) |
|----------------------------------------------------------------|
#+INCLUDE: toc.tex
#+LATEX: \clearpage
|------------------------------------------------------------------------------------------------------------|
| Programs are followed by their respective inputs and outputs i.e, both stdin and stdout are shown together |
|------------------------------------------------------------------------------------------------------------|
* Lab 1
#+INCLUDE: ./lab1/file.org
@@ -31,3 +40,19 @@
* Lab 6
#+INCLUDE: ./lab6/file.org
#+LATEX: \clearpage
* Lab 7
#+INCLUDE: ./lab7/file.org
#+LATEX: \clearpage
* Lab 8
#+INCLUDE: ./lab8/file.org
#+LATEX: \clearpage
* Lab 9
#+INCLUDE: ./lab9/file.org
#+LATEX: \clearpage
* Lab 10
#+INCLUDE: ./lab10/file.org
#+LATEX: \clearpage

BIN
file.pdf

Binary file not shown.

28
front.tex Normal file
View File

@@ -0,0 +1,28 @@
\newgeometry{left=1.5in,right=1.5in}
\begin{titlepage}
\vspace*{1.2in}
\begin{center}
{\fontsize{20}{24}\selectfont \textbf{\emp{OBJECT-ORIENTED PROGRAMMING USING C++}}}
\end{center}
\vspace{0.3in}
\hspace{0.3in}
\begin{minipage}{2in}
Faculty Name:\\
NITESH KUMAR\\
Assisstant Professor\\
I.T. Department
\end{minipage}
\hfill
\begin{minipage}{2in}
Student: AMNEESH SINGH\\
Enrollment: 14114803121\\
Semester: III\\
Group: I6
\end{minipage}
\begin{center}
\includegraphics[width=2in]{mait.png}\\
\fontsize{18}{22}\selectfont Maharaja Agrasen Institute of Technology, PSP Area, Sector-22, Rohini, New Delhi 110086
\end{center}
\end{titlepage}
\restoregeometry

26
lab10/28.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <fstream>
#include <iostream>
using namespace std;
const string FILE_PATH = "./28.in";
int main() {
string line;
fstream file;
file.open(FILE_PATH, ios_base::in);
if (!file.is_open())
exit(1);
while (getline(file, line)) {
cout << line;
if (file.peek() != EOF) {
cout << endl;
}
}
file.close();
return 0;
}

31
lab10/29.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <fstream>
#include <iostream>
using namespace std;
const string SRC_FILE_PATH = "./29.in";
const string DST_FILE_PATH = "./29.out";
int main() {
string line;
fstream src, dst;
src.open(SRC_FILE_PATH, ios_base::in);
dst.open(DST_FILE_PATH, ios_base::out);
dst.close();
dst.open(DST_FILE_PATH, ios_base::app);
if (!src.is_open())
exit(1);
while (getline(src, line)) {
dst << line;
if (src.peek() != EOF) {
dst << endl;
}
}
src.close();
dst.close();
return 0;
}

67
lab10/30.cpp Normal file
View File

@@ -0,0 +1,67 @@
#include <fstream>
#include <iostream>
#include <ostream>
using namespace std;
const string FILE_PATH = "./30.out";
class StudentInfo {
char name[30];
uint age;
char sex;
uint height;
public:
void read();
void write();
};
void StudentInfo::read() {
cout << "Name: ";
cin >> name;
cout << "Age: ";
cin >> age;
cout << "Sex (m/f): ";
cin >> sex;
cout << "Height: ";
cin >> height;
cout << "[LOG] Data read\n";
}
void StudentInfo::write() {
ofstream file(FILE_PATH);
file.close();
file.open(FILE_PATH, ios_base::app);
file << "Name: " << name << endl
<< "Age: " << age << endl
<< "Sex: " << (sex == 'm' ? "Male" : "Female") << endl
<< "Height: " << height << "cm";
cout << "[LOG] Data written\n";
file.close();
}
int main() {
StudentInfo foo;
string line;
foo.read();
foo.write();
ifstream file(FILE_PATH);
if (!file.is_open())
exit(1);
cout << "File contents: \n";
while (getline(file, line)) {
cout << line;
if (file.peek() != EOF) {
cout << endl;
}
}
return 0;
}

164
lab10/file.org Normal file
View File

@@ -0,0 +1,164 @@
* Write a program to read a text file and display its contents on the screen.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 28.cpp :wrap src text
#include <fstream>
#include <iostream>
using namespace std;
const string FILE_PATH = "./28.in";
int main() {
string line;
fstream file;
file.open(FILE_PATH, ios_base::in);
if (!file.is_open())
exit(1);
while (getline(file, line)) {
cout << line;
if (file.peek() != EOF) {
cout << endl;
}
}
file.close();
return 0;
}
#+end_src
#+begin_src text
Asperger syndrome (AS), also known as Asperger's, is a former neurodevelopmental disorder.
It is characterized by significant difficulties in social interaction and nonverbal communication.
#+end_src
#+LATEX: \clearpage
* Write a program to copy the contents of a file into another.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 29.cpp :wrap src text
#include <fstream>
#include <iostream>
using namespace std;
const string SRC_FILE_PATH = "./29.in";
const string DST_FILE_PATH = "./29.out";
int main() {
string line;
fstream src, dst;
src.open(SRC_FILE_PATH, ios_base::in);
dst.open(DST_FILE_PATH, ios_base::out);
dst.close();
dst.open(DST_FILE_PATH, ios_base::app);
if (!src.is_open())
exit(1);
while (getline(src, line)) {
dst << line;
if (src.peek() != EOF) {
dst << endl;
}
}
src.close();
dst.close();
return 0;
}
#+end_src
#+LATEX: \clearpage
* Write a program to read the class object of student_info such as name, age, sex, height and weight from the keyboard and to store them on a specified file using read() and write() functions. Again the same file is opened for reading and displaying the contents of the file on the screen.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 30.cpp :wrap src text
#include <fstream>
#include <iostream>
#include <ostream>
using namespace std;
const string FILE_PATH = "./30.out";
class StudentInfo {
char name[30];
uint age;
char sex;
uint height;
public:
void read();
void write();
};
void StudentInfo::read() {
cout << "Name: ";
cin >> name;
cout << "Age: ";
cin >> age;
cout << "Sex (m/f): ";
cin >> sex;
cout << "Height: ";
cin >> height;
cout << "[LOG] Data read\n";
}
void StudentInfo::write() {
ofstream file(FILE_PATH);
file.close();
file.open(FILE_PATH, ios_base::app);
file << "Name: " << name << endl
<< "Age: " << age << endl
<< "Sex: " << (sex == 'm' ? "Male" : "Female") << endl
<< "Height: " << height << "cm";
cout << "[LOG] Data written\n";
file.close();
}
int main() {
StudentInfo foo;
string line;
foo.read();
foo.write();
ifstream file(FILE_PATH);
if (!file.is_open())
exit(1);
cout << "File contents: \n";
while (getline(file, line)) {
cout << line;
if (file.peek() != EOF) {
cout << endl;
}
}
return 0;
}
#+end_src
#+begin_src text
Name: Hello
Age: 19
Sex (m/f): m
Height: 180
[LOG] Data read
[LOG] Data written
File contents:
Name: Hello
Age: 19
Sex: Male
Height: 180cm
#+end_src

View File

@@ -35,9 +35,6 @@ void Student::input() {
cout << "Gender (m/f): ";
cin >> this->gender;
if (this->gender != 'm' || this->gender != 'f')
exit(1);
cout << "Enter Marks for" << endl;
for (i = 0; i < NSUBS; i++) {
@@ -64,6 +61,8 @@ int main() {
for (i = 0; i < NSTUDENTS; i++)
a[i].input();
cout << "\nStudents with percentage greater than 70:\n";
for (i = 0; i < NSTUDENTS; i++)
if (a[i].getPercentage() > 70)
cout << a[i].getName() << endl;

View File

@@ -100,11 +100,6 @@ int main() {
}
#+end_src
#+RESULTS:
#+begin_src text
-8 -3689 4 28892
6 1227 -4 -9718
#+end_src
#+LATEX: \clearpage
* Create a class TIME with members hours, minutes, seconds. Take input, add two time objects passing objects to function and display the result. [Hint: use class object as parameter of function add()]
@@ -169,17 +164,12 @@ int main() {
}
#+end_src
#+RESULTS:
#+begin_src text
Hours: 68
Minutes: 32
Seconds: 0
#+end_src
#+LATEX: \clearpage
* Create a class Student which has data members as name, branch, roll no, age , gender, marks in five subjects. Display the name of the student and his percentage who has more than 70%.Use array of objects size 5.[Hint: also declare percentage variable and calculate it and then compare all the object of student class to find name of student with percentage > 70]
#+begin_src cpp :tangle 6.cpp :results output :exports both :wrap src text
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 6.cpp :results output :wrap src text
#include <iostream>
using namespace std;
@@ -217,9 +207,6 @@ void Student::input() {
cout << "Gender (m/f): ";
cin >> this->gender;
if (this->gender != 'm' || this->gender != 'f')
exit(1);
cout << "Enter Marks for" << endl;
for (i = 0; i < NSUBS; i++) {
@@ -246,6 +233,8 @@ int main() {
for (i = 0; i < NSTUDENTS; i++)
a[i].input();
cout << "\nStudents with percentage greater than 70:\n";
for (i = 0; i < NSTUDENTS; i++)
if (a[i].getPercentage() > 70)
cout << a[i].getName() << endl;
@@ -253,3 +242,56 @@ int main() {
return 0;
}
#+end_src
#+begin_src text
Name: Amaang
Branch: InformationTechnology
Enter Enrollment number: 413
Age: 14
Gender (m/f): m
Enter Marks for
Subject 1: 99
Subject 2: 93
Subject 3: 9
Subject 4: 91
Subject 5: 3
Name: Allu
Branch: Physics
Enter Enrollment number: 444
Age: 19
Gender (m/f): f
Enter Marks for
Subject 1: 100
Subject 2: 0
Subject 3: 100
Subject 4: 0
Subject 5: 100
Name: Asli
Branch: Law
Enter Enrollment number: 33
Age: 99
Gender (m/f): m
Enter Marks for
Subject 1: 1
Subject 2: 1
Subject 3: 1
Subject 4: 1
Subject 5: 2
Name: how
Branch: Music
Enter Enrollment number: 9999
Age: 9
Gender (m/f): m
Enter Marks for
Subject 1: 12
Subject 2: 22
Subject 3: 32
Subject 4: 42
Subject 5: 52
Name: sabji
Branch: CivilEngineering
Enter Enrollment number: 91
Students with percentage greater than 70:
sabji
#+end_src

View File

@@ -28,10 +28,6 @@ int main() {
}
#+end_src
#+RESULTS:
#+begin_src text
Factorial of 5 is 120
#+end_src
#+LATEX: \clearpage
* Write a program to perform addition of two complex numbers using constructor overloading. The first constructor which takes no argument is used to create objects which are not initialized, second which takes one argument is used to initialize real and imag parts to equal values and third which takes two arguments is used to initialize real and imag to two different values.
@@ -85,14 +81,10 @@ int main() {
}
#+end_src
#+RESULTS:
#+begin_src text
38-2120i
#+end_src
#+LATEX: \clearpage
#+ATTR_LATEX: :options frame=single,breaklines=true
* Write a program to generate a Fibonacci series using a copy constructor.
#+begin_src cpp :tangle 9.cpp :results output :exports both :wrap src text
#include <iostream>
using namespace std;

View File

@@ -29,15 +29,12 @@ int main() {
}
#+end_src
#+RESULTS:
#+begin_src text
444
#+end_src
#+LATEX: \clearpage
* Write a program to demonstrate the use of friend function with Inline assignment.
All friend functions are inline functions.
#+ATTR_LATEX: :options frame=single,breaklines=true
* Write a program to find the greatest of two given numbers in two different classes using friend function.
#+begin_src cpp :tangle 12.cpp :results output :exports both :wrap src text
#include <algorithm>
@@ -74,8 +71,3 @@ int main() {
cout << bigger(a, b);
}
#+end_src
#+RESULTS:
#+begin_src text
55
#+end_src

22
lab7/19.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include <iostream>
using namespace std;
class Foo {
int x;
public:
Foo(int _x) { x = _x; };
Foo &operator++();
int get() { return x; }
};
Foo &Foo::operator++() {
x++;
return *this;
}
int main() {
Foo bar = Foo(-3);
++bar;
cout << bar.get();
}

22
lab7/20.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include <iostream>
using namespace std;
class Foo {
int x;
public:
Foo(int _x) { x = _x; };
Foo operator+(Foo);
int get() { return x; }
};
Foo Foo::operator+(Foo bar) {
return Foo(x + bar.get());
}
int main() {
Foo bar = Foo(-3);
Foo baz = Foo(8);
cout << (bar + baz).get();
}

22
lab7/21.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include <iostream>
using namespace std;
class Foo {
int x;
public:
Foo(int _x) { x = _x; };
Foo operator*(Foo);
int get() { return x; }
};
Foo Foo::operator*(Foo bar) {
return Foo(x * bar.get());
}
int main() {
Foo bar = Foo(-3);
Foo baz = Foo(8);
cout << (bar * baz).get();
}

87
lab7/file.org Normal file
View File

@@ -0,0 +1,87 @@
* Write a program to overload (++) operator.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 19.cpp :results output :exports both :wrap src text
#include <iostream>
using namespace std;
class Foo {
int x;
public:
Foo(int _x) { x = _x; };
Foo &operator++();
int get() { return x; }
};
Foo &Foo::operator++() {
x++;
return *this;
}
int main() {
Foo bar = Foo(-3);
++bar;
cout << bar.get();
}
#+end_src
#+LATEX: \clearpage
* Write a program to overload + operator.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 20.cpp :results output :exports both :wrap src text
#include <iostream>
using namespace std;
class Foo {
int x;
public:
Foo(int _x) { x = _x; };
Foo operator+(Foo);
int get() { return x; }
};
Foo Foo::operator+(Foo bar) {
return Foo(x + bar.get());
}
int main() {
Foo bar = Foo(-3);
Foo baz = Foo(8);
cout << (bar + baz).get();
}
#+end_src
#+LATEX: \clearpage
* Write a program to overload * operator.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 21.cpp :results output :exports both :wrap src text
#include <iostream>
using namespace std;
class Foo {
int x;
public:
Foo(int _x) { x = _x; };
Foo operator*(Foo);
int get() { return x; }
};
Foo Foo::operator*(Foo bar) {
return Foo(x * bar.get());
}
int main() {
Foo bar = Foo(-3);
Foo baz = Foo(8);
cout << (bar * baz).get();
}
#+end_src

19
lab8/22.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include <iostream>
template <typename T, std::enable_if_t<std::is_arithmetic<T>::value, T> = 0>
void swap(T &x, T &y) {
x += y;
y = x - y;
x -= y;
}
int main() {
char x = '[';
char y = 'w';
swap(x, y);
std::cout << "x = " << x << ", y = " << y;
return 0;
}

14
lab8/23.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include <iostream>
template <typename T>
std::enable_if_t<std::is_arithmetic<T>::value, T> sq(T x) {
return x * x;
}
int main() {
float x = 4.4;
std::cout << "double: " << sq((double)5.3) << "\nlong: " << sq(4l);
return 0;
}

19
lab8/24.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include <iostream>
template <typename T>
std::enable_if_t<std::is_integral<T>::value, T> fn(T x) {
return x * x;
}
template <typename T>
std::enable_if_t<std::is_floating_point<T>::value, T> fn(T x) {
return --x;
}
int main() {
float x = 4.4;
std::cout << "floating: " << fn((double)5.3) << "\nintegral: " << fn(4l);
return 0;
}

73
lab8/file.org Normal file
View File

@@ -0,0 +1,73 @@
* Write a program to define the function template for swapping two items of the various data types such as integer ,float,and characters.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 22.cpp :results output :exports both :wrap src text
#include <iostream>
template <typename T, std::enable_if_t<std::is_arithmetic<T>::value, T> = 0>
void swap(T &x, T &y) {
x += y;
y = x - y;
x -= y;
}
int main() {
char x = '[';
char y = 'w';
swap(x, y);
std::cout << "x = " << x << ", y = " << y;
return 0;
}
#+end_src
#+LATEX: \clearpage
* Write a program to define the function template for calculating the square of given numbers with different data types.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 23.cpp :results output :exports both :wrap src text
#include <iostream>
template <typename T>
std::enable_if_t<std::is_arithmetic<T>::value, T> sq(T x) {
return x * x;
}
int main() {
float x = 4.4;
std::cout << "double: " << sq((double)5.3) << "\nlong: " << sq(4l);
return 0;
}
#+end_src
#+LATEX: \clearpage
* Write a program to illustrate how template functions can be overloaded.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 24.cpp :results output :exports both :wrap src text
#include <iostream>
template <typename T>
std::enable_if_t<std::is_integral<T>::value, T> fn(T x) {
return x * x;
}
template <typename T>
std::enable_if_t<std::is_floating_point<T>::value, T> fn(T x) {
return --x;
}
int main() {
float x = 4.4;
std::cout << "floating: " << fn((double)5.3) << "\nintegral: " << fn(4l);
return 0;
}
#+end_src

26
lab9/25.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <iostream>
using namespace std;
template <typename T,
typename = enable_if_t<std::is_arithmetic<T>::value, T>>
class Foo {
T x, y;
public:
Foo() {
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
}
T sum() { return x + y; };
};
int main() {
Foo<float> bar;
cout << bar.sum();
return 0;
}

BIN
lab9/26 Executable file

Binary file not shown.

28
lab9/26.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;
template <class T,
class = enable_if<is_arithmetic<T>::value, T>>
class Foo {
T x, y;
public:
Foo() {
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
}
~Foo() { cout << "Destructor called, nothing to do here."; }
T mx() { return (x > y ? x : y); };
};
int main() {
Foo<float> bar;
cout << bar.mx() << endl;
return 0;
}

26
lab9/27.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <fstream>
#include <iostream>
using namespace std;
const string FILE_PATH = "./27.out";
int main() {
string line;
cout << "Running program till the string \"EOH\" is received via stdin"
<< endl;
ofstream file(FILE_PATH);
file.close();
file.open(FILE_PATH, ios_base::app);
while (getline(cin, line)) {
if (line == "EOH")
break;
file << line << endl;
}
file.close();
return 0;
}

123
lab9/file.org Normal file
View File

@@ -0,0 +1,123 @@
* Write a program to illustrate how to define and declare a class template for reading two data items from the keyboard and to find their sum.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 25.cpp :wrap src text
#include <iostream>
using namespace std;
template <typename T,
typename = enable_if_t<std::is_arithmetic<T>::value, T>>
class Foo {
T x, y;
public:
Foo() {
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
}
T sum() { return x + y; };
};
int main() {
Foo<float> bar;
cout << bar.sum();
return 0;
}
#+end_src
#+begin_src text
x: 4.3
y: 9.1
13.4
#+end_src
#+LATEX: \clearpage
* Write a program to demonstrate the use of special functions, constructor and destructor in the class template. The program is used to find the biggest of two entered numbers.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 26.cpp :wrap src text
#include <iostream>
using namespace std;
template <class T,
class = enable_if<is_arithmetic<T>::value, T>>
class Foo {
T x, y;
public:
Foo() {
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
}
~Foo() { cout << "Destructor called, nothing to do here."; }
T mx() { return (x > y ? x : y); };
};
int main() {
Foo<float> bar;
cout << bar.mx() << endl;
return 0;
}
#+end_src
#+begin_src text
x: 3.4
y: 9.1
9.1
Destructor called, nothing to do here.
#+end_src
#+LATEX: \clearpage
* Write a program to read a set of lines from the keyboard and to store it on a specified file.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src cpp :tangle 27.cpp :wrap src text
#include <fstream>
#include <iostream>
using namespace std;
const string FILE_PATH = "./27.out";
int main() {
string line;
cout << "Running program till the string \"EOH\" is received via stdin"
<< endl;
ofstream file(FILE_PATH);
file.close();
file.open(FILE_PATH, ios_base::app);
while (getline(cin, line)) {
if (line == "EOH")
break;
file << line << endl;
}
file.close();
return 0;
}
#+end_src
#+begin_src text
Running program till the string "EOH" is received via stdin
i have a
flayed dismembered
corpse in front of my
lawn
EOH
#+end_src

BIN
mait.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

65
toc.tex Normal file
View File

@@ -0,0 +1,65 @@
\begin{center}
\fontsize{15}{18}\selectfont \textbf{
OBJECT-ORIENTED PROGRAMMING USING C++ LAB\\
PRACTICAL RECORD
}
\end{center}
\begin{table}[h]
\begin{tabular}{lcl}
Paper Code & : & CIC-257\\
Name of the student & : & Amneesh Singh\\
University Enrollment number & : & 14114803121\\
Branch & : & Information Technology\\
Group & : & I6
\end{tabular}
\end{table}
\textbf{PRACTICAL DETAILS}
Experiments according to the lab syllabus prescribed by GGSIPU
\fontsize{11}{12}\selectfont
\renewcommand{\arraystretch}{2.5}
\begin{longtable}{|p{0.6cm}|p{8cm}|p{2cm}|p{2cm}|p{2cm}|p{1cm}|} \hline
\textbf{Exp. No.} & \textbf{Experiment Name} & \textbf{Performance Date} & \textbf{Date Checked} & \textbf{Remarks} & \textbf{Marks} \\ \hline \hline
1 & Write a program to take name, address as a character array, age as int, salary as float and contains inline functions to set the values and display it in class named person & & & & \\ \hline
2 & Using the concept of function overloading.Write function for calculating the area of triangle, circle and rectangle & & & & \\ \hline
3 & Write a program to find number m to power n. The function power takes a double value for m and int value for n. Use default value for n to make the function to calculate squares when this argument is omitted & & & & \\ \hline
4 & Write a program for multiplication of two matrices using OOP & & & & \\ \hline
5 & Create a class TIME with members hours, minutes, seconds. Take input, add two time objects passing objects to function and display the result & & & & \\ \hline
6 & Create a class Student which has data members as name, branch, roll no, age , gender, marks in five subjects. Display the name of the student and his percentage who has more than 70\%.Use array of objects size 5 & & & & \\ \hline
7 & Write a program to enter any number and find its factorial using constructor & & & & \\ \hline
8 & Write a program to perform addition of two complex numbers using constructor overloading. The first constructor which takes no argument is used to create objects which are not initialized, second which takes one argument is used to initialize real and imag parts to equal values and third which takes two arguments is used to initialize real and imag to two different values & & & & \\ \hline
9 & Write a program to generate a Fibonacci series using a copy constructor & & & & \\ \hline
10 & Write a program to find the biggest of three numbers using friend function & & & & \\ \hline
11 & Write a program to demonstrate the use of friend function with Inline assignment & & & & \\ \hline
12 & Write a program to find the greatest of two given numbers in two different classes using friend function & & & & \\ \hline
13 & Imagine a publishing company that markets both book and audiocassette versions of its works. Create a class publication that stores the title (a string) and price (type float) of a publication. From this class derive two classes: book, which adds a page count (type int), and tape, which adds a playing time in minutes (type float). Each of these three classes should have a getdata() function to get its data from the user at the keyboard, and a putdata() function to display its data. (Simple inheritance and method overriding) & & & & \\ \hline
14 & C++ program to read and print employee information using multiple inheritance. The program has following classes: & & & & \\
& 1. basicInfo & & & & \\
& a. Data: name[char,30],empId[int], gender[char] & & & & \\
& b. Functions: getData(), putData(); & & & & \\
& 2. deptInfo & & & & \\
& a. Data: deptName[char,30], assignWork[char,30], timeToComplete(int) & & & & \\
& b. Functions: getData(), putData(); & & & & \\
& 3. employeeInfo & & & & \\
& a. Data: salary[int], age[int] & & & &\\
& b. Functions: getData(), putData(); & & & & \\ \hline
14 & Design three classes STUDENT ,EXAM and RESULT. The STUDENT class has data members such as rollno, name. create a class EXAM by inheriting the STUDENT class. The EXAM class adds data members representing the marks scored in six subjects. Derive the RESULT from the EXAM class and has its own data members such as total marks. Write a program to model this relationship & & & & \\ \hline
16 & Create class first with data members book no, book name and member function getdata and putdata. Create a class second with data members author name ,publisher and members getdata and showdata. Derive a class third from first and second with data member no of pages and year of publication. Display all these information using an array of objects of third class & & & & \\ \hline
17 & Create a base class called SHAPE. Use this class to store two double type values. Derive two specific classes called TRIANGLE and RECTANGLE from the base class. Add to the base class, a member function getdata to initialize base class data members and another member function display to compute and display the area of figures. Make display a virtual function and redefine this function in the derived classes to suit their requirements. Using these three classes design a program that will accept driven of a TRIANGLE or RECTANGLE interactively and display the area & & & & \\ \hline
18 & Create a base class basic_info with data members name, roll no, gender and two member functions getdata and display. Derive a class physical\_fit from basic\_info which has data members height and weight and member functions getdata and display. Display all the information using object of derived class & & & & \\ \hline
19 & Write a program to overload less than ++ operator & & & & \\ \hline
20 & Write a program to overload less than + operator & & & & \\ \hline
21 & Write a program to overload less than * operator & & & & \\ \hline
22 & Write a program to define the function template for swapping two items of the various data types such as integer ,float,and characters & & & & \\ \hline
23 & Write a program to define the function template for calculating the square of given numbers with different data types & & & & \\ \hline
24 & Write a program to illustrate how template functions can be overloaded & & & & \\ \hline
25 & Write a program to illustrate how to define and declare a class template for reading two data items from the keyboard and to find their sum & & & & \\ \hline
26 & Write a program to demonstrate the use of special functions, constructor and destructor in the class template. The program is used to find the biggest of two entered numbers \\ \hline
27 & Write a program to read a set of lines from the keyboard and to store it on a specified file & & & & \\ \hline
28 & Write a program to read a text file and display its contents on the screen & & & & \\ \hline
29 & Write a program to copy the contents of a file into another & & & & \\ \hline
30 & Write a program to read the class object of student\_info such as name, age, sex, height and weight from the keyboard and to store them on a specified file using read() and write() functions. Again the same file is opened for reading and displaying the contents of the file on the screen & & & & \\ \hline
\end{longtable}