Header Ads Widget

Ticker

6/recent/ticker-posts

Object Oriented Programming(OOP) Practicals

 LIST OF PRACTICALS

Sr.Practical TitleAnswer
1Design a simple class with all arithmetic function. Use them in MAIN function.
Create a class student with student name and age as data members. Define functions to read and display the data members.
Create a String class that includes all the string-related functions. Like Length, copy, compare, concatenation, sub string search (Without using inbuilt string functions).
Solution
2Write a program to find the largest of three integers using a swap function. The function accepts integer arguments by reference.
Design classes named Triangle, Square, and Circle. Make the different function in each class to find areas of particular shape. Create a class with string pointer as data member and member functions: 
Solution
3Constructor to allocate memory dynamically and read value.
Display () function to display the string.
Destructor function to free allocated memory
Solution
4Write a function that creates an array of user given size using new operator. Define a class to represent a bank account. Include the members like name of the depositor, account number, type of account, and balance amount in the account. Make functions
(1) To assign initial values,
(2) To deposit an amount,
(3) To withdraw an amount after checking the balance,
(4) To display name and balance.
Write a main program to test the program. Create a C++ program to convert temperature in Fahrenheit to celcius and display. Use class
Solution
5Create a 'DISTANCE' class with : - feet and inches as data members, - member function to input distance- member function to output distance- member function to add two distance objects. Write a main function to create objects of DISTANCE class. Input two distances and output the sum.
Write a function that creates a vector of user given size M using new operator. Demonstrate the use of the function.
Write a C++ program to swap two number by both call by value and call by reference mechanism, using two functions swap_value() and swap_reference respectively , by getting the choice from the user and executing the user’s choice by switch-case.
Solution
6Write a C++ program to implement function overloading in order to compute power(m,n) where
(1) m is double and n is int
(2) m and n are int.
Create a function called reverse () that takes two parameters. The first parameter, called str is a pointer to a string that will be reversed upon return from the function. The second parameter is called count, and it specifies how many characters of str to reverse. Give count a default value that, when present, tells reverse () to reverse the entire string.
Write a program to demonstrate the use of arrays within a class. Create and manage an inventory system.
Solution
7Create a program to understand and use static members and static member functions. Create a class employee with suitable members and functions. Create an array of objects and demonstrate the use of the class using the main function.
Create a class time with members hours and minutes. Write a member function ‘add’ which takes 2 arguments of type class time and demonstrate the use with a main program.
Solution
8Create a class sample with members a and b of type integer. Write a friend function that takes an object as argument and calculates the mean of the two members.
Create a class complex that has two members of type float. Write a friend function that calculate the sum of the two complex objects and returns the result as an object. Demonstrate the working using a main function.
For the complex Class, demonstrate the use of multiple constructors. Write a program to demonstrate the use of copy constructor
Solution
9Construct a two-dimensional array using dynamic constructors. Write a program to overload the + and – operators for the complex class. 28. Write a program to overload the unary – operator for a suitable classSolution
10Write a program to overload the + and == operators for the string class.
Write a program to overload the [] operator.
Write a program to overload the << and >> operators.
Write a program to convert a basic type to a class type and vice versa
Solution
11Write a program to convert an object of one class to another class.
Design a class Polar which describes a point in the plane using polar coordinates radius and angle. Use overloaded + operator to add two polar objects.
Define two classes Polar and Rectangle to represent points in the polar and rectangular systems. Use conversion routines to convert from one system to the other.
Solution
12Write a program to implement single inheritance. Show the consequences of deriving a class in public, protected and private manner with a simple example. Consider a simple example. Class student stores the roll-number, class test stores the marks in two subjects and class result contains the total marks obtained in the test. The class result inherits the details of the marks obtained and roll number of students through multilevel inheritance. Write a program to demonstrate the above. Extend the program in (2) to add a sports class. The result class inherits the details of marks obtained from class test and the performance in sports from the sports class (hybrid inheritance).Solution
13Write a program to demonstrate how parameters are passed to the base class constructor via the derived class constructor.
Write a program to use the following functions: Put(), Get(), Getline(), Write()
Write a program to produce formatted output using the following functions: Width(), Precision(), Fill(), Setf(), Unsetf()
Solution
14Use various flags and bit fields to produce formatted output. Write a program to use manipulators setw, setiosflags and setprecision for formatted output. Write a program to read a list containing item name, item code, and cost interactively and produce a three column output as shown below.
 NAME CODE COST
____________________________
Turbo C++ 1001 250.95
C Primer 905 95.70
….. … ..… ….. … …..
____________________________ 
Solution
15Write a program to create files with constructor function, open function, and using various file mode parameters.
Write a program to use the following functions: Seekg(), Tellg(), Seekp(), Tellp(), Put(), Get(), Write(), Read() Basic Python programs
Solution

Post a Comment

0 Comments