DEHRADUN CAMPUS
Term Work
OOPS WITH C++
TCS - 307
B.TECH CSE
III
2023 - 24
DEPARTMENT OF COMPUTER SCIENCE
AND ENGINEERING
Submitted By : Submitted To :
Name : ADTIYA RAJ KOTHARI
University Roll No. : 22151793 Department of Computer Science and
Class Roll No. : 07 Engineering,
Course/Section: B.TECH / M1 Graphic Era Hill University DDN.
DEHRADUN CAMPUS
CERTIFICATE
UNIVERSITY ROLL NO. : 22151793 CLASS ROLL NO.: 07
THIS IS TO CERTIFY THAT MR. ADTIYA RAJ KOTHARI OF
B.TECH CSE 2nd YEAR HAS SATISFACTORILY COMPLETED
HIS TERM WORK AS PER THE CURRICULUM DESIGNED BY
GRAPHIC ERA HILL UNIVERSITY DEHRADUN CAMPUS FOR
THE BATCH 2022-2026.
—-----------
FACULTY
SIGNATURE
DEHRADUN CAMPUS
ACKNOWLEDGEMENT
I WOULD LIKE TO CONVEY MY THANKS TO MY GUIDE DR
AAKASH CHAUHAN FOR HIS IMMENSE HELP AND GUIDANCE
IN THE COMPLETION OF MY LAB WORK. IT IS ONLY POSSIBLE
DUE TO THEIR EFFORTS THAT MY LAB WORK COULD BE
COMPLETED SUCCESSFULLY WELL ON TIME. THEY GLADLY
ACCEPTED ALL THE PAINS IN GOING THROUGH AND
PARTICIPATED IN ENLIGHTENING AND MOTIVATING
DISCUSSIONS, WHICH WERE EXTREMELY FRUITFUL.
—-----------
FACULTY SIGNATURE
INDEX
S.N PRACTICAL D.O.P D.O.S GRADE GRaD TOTAL STUDENT’S TEACHER’S
O. (VIVA) E MARKS SIGNATUR SIGNATUR
(REP E E
ORT
FILE)
1. Pattern printing.
2. Write a program in C++ to
display the multiplication
table vertically from 1 to n.
3. Write a program in C++ to
display the sum of the series [
9 + 99 + 999 + 9999 …].
4. Write a C++ program to sort
a given array of 0s, 1s and
2s. In the final array put all
0s first, then all 1s and all 2s
in last.
5. Create a string (using both
approaches – C Style string
and string class) and carry out
following operations:
– Reverse a string
– Sort a string
– Convert a string into Upper
Case
6. Accept a string from the user
and print the number of times
each character is appearing in
the string.
7. Create a C++ program to
perform survey on four
different model of Maruti
(Maruti - K10, Zen-Astelo,
Wagnor, Maruti- SX4) owned
by person living in four
metro cities(Delhi, Mumbai,
Chennai & Kolkata). Display
tabulated report like format
given.
8. Create an inline function which
accepts a number and checks
whether its Armstrong or not.
9. Create a class Room, which
includes following members
a. Length
b. Breadth
c. Height
And Methods
a. CalculateArea()
b. CalculateVloume()
c. Display()
10. Create a Class MyClass. Which
includes data Member
a. Value
And Methods
a. SetValue() pass
parameter
b. GetValue() return
parameter
11. Write a program to implement
an array of objects.
12. Create a Class MyClass.
Which includes data
Member Value And Methods
SetValue() pass parameter
GetValue() return
parameter.
13. Write a program to count the
number of objects created for a
class using a constructor.
14. Write a program to
compare two objects using
friend functions.
15. Create a class of Employ, in
that considers their names,
age, and employee code. In the
same class, create a -
(subtract) overloading operator
to find the age gap of two
employees?
16. Write a C++ program to use
scope resolution operators.
Display the various values of
the same variables declared at
different scope levels.
17. We want to calculate the total
marks of each student of a
class in Physics,Chemistry and
Mathematics and the average
marks of the class. The
number of students in the class
are entered by the user. Create
a class named Marks with data
members for roll number,
name and marks. Create three
other classes inheriting the
Marks class, namely Physics,
Chemistry and Mathematics,
which are used to define marks
in individual subjects of each
student. Roll number of each
student will be generated
automatically.
18. We want to store the
information of different
vehicles. Create a class named
Vehicle with two data member
named mileage and price.
19. Create a class named Shape
with a function that prints
"This is a shape". Create
another class named Polygon
inheriting the Shape class with
the same function that prints
"Polygon is a shape".
20. Implement a C++ program
that demonstrates runtime
polymorphism with a base
class Animal and three derived
classes Dog, Cat, and Bird.
Each class should have a
sound() function that prints
the sound the animal makes.
21 Write a program to create a
class named shape. In this
class we have three sub classes
circle, triangle and square each
class has two member function
named draw () and erase ().
Implements these function
using runtime polymorphism
concepts.
22. Solve the following problem by
using runtime polymorphism:
Following tables outlines the
major credit cards you might
want to validate, along with
their allowed prefixes and
lengths. Major Credit Cards,
Their Prefixes, and Lengths.
23. Define an exception class
called “MyNation” that is
thrown when a string is not
equal to “jai hind” or “JAI
HIND”. Write a program that
implements this exception.
24. Define an exception class
called InvalidAgeException
that accept user’s age and
if the age is less than 18
then throw an exception
with suitable error message
and catch it by displaying
that message.
25. Write a program to copy the
contents of one text file to
another while changing the
case of every alphabet."
26. Write a program to count
number of character, words
and lines in a file.
27. A file 'Employee.txt'
contains empno and
empname. Write a C++
program to add and read
contents of this file and
search for an employee
whose name is 'XYZ'.
28. Write a C++ program to store
student id and name in a STL
container. Sort the student id
in ascending order and then
print their corresponding
names.
29. Write a program to create a
vector, accept 10 numbers
from the user, insert them
one by one into the vector,
remove the last element
from the vector and then
print the elements of the
vector in reverse order.