Friday, February 27, 2009

OOPS ASSIGNMENT - 8

Recursive Member Function

1.Write a program to find the factorial of a number using recursive member function.

2.write a program to find the sum of the digits of a number using recursive member function.

3.write a program to find the sum of n numbers using recursive member function.

4.write a program to find the gcd of two numbers using recursive member function.

Recursive constructor
1.write a program to find the factorial of a number using recursive constructor.

2.write a program to find the sum of n numbers using recursive constructor.

3.write a program to find the sum of the digits using recursive constructor.

4.write a program to find the gcd of two numbers using recursive constructor.

OOPS ASSIGNMENT - 7

Constructors and Destructors
1.write a program using constructor to find the area of a rectangle. This includes two data members(length and width), two member functions one is to display the length and width, other is to calculate the area and display that area.

2.Create a class to store a string. Include member functions to input and output the data member. Write the above program using constructor and destructor.

3. Write a C++ program by using the parameterized constructor.

4. Write a program by using the copy constructor concept to accept a number display that number.

5. Implement and test a class complex to store
.Real
.Imaginary

Include following constructors
.Default (to initialize both data members by zero value)
. One argument (to initialize both data members by a single value)
.Multiple argument (to initialize both data members by different value)
· Copy

Include destructor

6. Create a class to store string dynamically
Include following constructors
· Default (to initialize string to null value)
· One argument (to initialize string by a given value)
· Copy

7. WAP to implement a polynomial class having data members’ coefficient, base and power. For example, the polynomial 2x5 has the coefficient 2, base x and power 5. Include default and parameterized constructor and also include a member function evaluate () to find the value of the polynomial.

For example, if the polynomial is 2x5.
X=2, 2x5=64 is the answer.

Monday, February 16, 2009

Assignment-6

Q.1: Program to add two complex numbers using objects as arguments.

Q.2: Program to add time in hour and min using objects as argument.

Q.3. Create a class using friend function to calculate the mean of two values and parameter for the mean function should be object of the same class.

Q4.Create two classes using friend function i.e max to find the maximum value and parameters for the max function are two objects of the two classes.

Q.5.A library uses computer based information system for keeping track of its collection. With each book the information system stores the following information.
(i) Accession no of the book (an integer)
(ii) issue code with I,B,L,A indicating issued to a member, send for binding, Issued to another library and available respectively
(iii) Identity of the member which is an alphanumeric quantity.

The services extended by the library are
(a) Provides status of a requested book
(b) Provides list of all issued book

Q.6. Create two classes A & B with data members i and j respectively. Include friend function swap () to swap the values in the data members of the two classes.

Q.7.WAP to count and display the number of objects created in a class. (Use static variable)
(c) Provides list of books issued to a member