INDORE INSTITUTE OF Course: BTech
SCIENCE & Branch: CSE(DS)
TECHNOLOGY, INDORE Sub Code: CD 305
Subject: Object Oriented Programming and
Methodology
Faculty: Dr. Reetu Gupta
List of Experiments
Q.1. Write a program to find largest number among three numbers give as
input. (Control Statements)
Q.2. Write a program to print table of a given number. (Loops)
Q.3 Write a program to print following pattern (take number of rows as input)
(Loops)
A
BC
DEF
GHIJ
KLMNO
Q.4 Write a program to find and print the grade of a student. (Use switch-case
statement). The following table shows the grading system.
Score in subject Grade
>=90 A
80-89 B
70-79 C
60-69 D
50-59 E
<50 F
Q.5 Write a program, which first displays first N natural numbers. Then
calculate their sum and average. (Loops)
Q.6. Write a program to calculate sum of first 10 odd and even numbers starting
from 1. (Loops)
Q.7. Write a program to perform linear search in an integer array. (Arrays)
Q.8. Write a program to calculate factorial of a given number. (Functions)
Q.9 Write a program to find minimum and maximum element in an array of
10 elements.
Q.10 Write a program to check whether a number is palindrome or not.
(Functions)
Q.11 Write a menu-based program to traverse, find minimum, find maximum,
calculate sum, and calculate average of the given one-dimensional array.
Menu: 1. Traverse the array
2. Find min
3. Find max
4. Calculate Sum
5. Calculate Average
Q.12 Write a program to swap two values using:
a) Call by Value
b) Call by Pointers
c) Call by Reference
Q.13. Create a class Distance that contains two data items, feet and inches. The part feet
is of integer type and inches is of float type. The class Distance also has three
member functions: setdist(), which uses arguments to set feet and inches;
getdist(), which gets values for feet and inches from the user at the keyboard; and
showdist(), which displays the distance in feet-and-inches format.
(Objective: Learning C++ Objects as Data Type)
Q.14 Write a program to create functions which calculate the area of different
geometric figures. The function name: area() is used wherein it calculates
different values on different types of inputs like when given a single value, it
calculates the area of a square. For two inputs, it returns area assuming that the
figure is a rectangle. When a floating-point number is passed to the function, it
calculates and returns the area of a circle. (Objective: Function Overloading)
Q.15 Create a C++ class Date which contains:
- Day
- Month
- Year
Write constructor to initialize Date object by 01/01/2001. Write necessary
member functions to set_date() and display_date().
(Objective: Learning Constructors)
Q.16 Write a program to create a class that represents Class for Complex numbers
containing real and imaginary parts. Use the class to perform addition,
subtraction, multiplication and division of two complex numbers.
(Objective: Learning Concept of objects, passing object as arguments,
returning object from methods)
Q.17 Write a C++ program to perform arithmetic operations ‘+’ and ‘-‘ on Complex
number. Use operator overloading to solve the problem.
Q.18 Write a program to create and use time class to perform basic operations like
convertTo12 and convertTo24 format. It should have proper constructors and
functions to display the time.
(Objective: Default and Parameterized Constructors, Constructor
Overloading)
Q.19 Write a C++ class to implement inheritance shown in figure below. Redefine the
base class functions in derived classes. Write driver code in main().
Employee
char name[20]; //employee name
long e_id; //employee id
void getdata();
void putdata();
Manager Scientist
char dept[20]; //department name int publications;
double dues; //dues //overload functions from base class
//overload functions from base class
Q.20 Write a student class, which uses object of result class to display the result of
student.
Academic_Marks Sports
protected: protected:
int marks_math,marks_phy,marks_chem; int spmarks;
public: public:
void getmarks(); void getsports();
result
int total_marks;
float avg_marks;
void display();