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

Friday, January 30, 2009

OOPS ASSIGNMENT- 5

1. Create a class A with data members i and j respectively. Include a function swap () to swap the values in the data members.


2. WAP to calculate simple interest by passing the principal amount, rate of interest and time period as argument to function. Make rate of interest and time period default argument with default values 1.2 and 3 respectively


3. Raising a number n to power p is the same as multiplying by itself t times. Write a function called power ( ) that makes a double value for n and an int value for p and returns the result as double value. Use default argument of 2 for p, so that if this argument is omitted, the number will be squared. Write a main( ) function that gets values
from the user to test this function.


4 Write a function “increment” which takes two arguments and increment the first argument by second pass the argument to this function from main and print the increment value in the main function (use reference variable).

Friday, January 23, 2009

OOP ASSIGNMENT - 4

1. Write a class “employee” to store following information Name, employee ID, Age, Marital Status, and Salary. WAP to store information for 3 employees and display the results.

2. Implement a class “number” having data members value This class has a member function FindDigit() to count the occurrences of each digit in number object. Ex-If value = 1123, O/P = 1-Two times, 2 – One times and 3- One times

3.Define a class named Complex for representing complex numbers. A complex
number has the general form a + ib, where a is the real part and b is the imaginary
part (i stands for imaginary). Complex arithmetic rules are as follows:
(a + ib) + (c + id) = (a + c) + i(b + d)
(a + ib) – (c + id) = (a + c) – i(b + d)
(a + ib) * (c + id) = (ac – bd) + i(bc + ad)
Define these operations as member functions of Complex.

4. Create a string by using class , encrypt it & display it according to given instructions. A-Z, a-z, 0-9,’=’, ’,’, ’.’------- No changes. The space is replaced by ‘+’. Any other character is replaced by ‘%’ followed by ASCII value of that character.

Wednesday, January 21, 2009

OOPS ASSIGNMENT - 3

1. Write a program which inputs a positive integer n and outputs 2 raised to the power of n.

2. WAp to calculates the weekly gross pay for a worker, based on the total number of hours worked and the hourly payrate.

Hint. weeklyPay = workDays * workHours * payRate

3. Write a program which inputs a temperature reading expressed in Fahrenheit and outputs its equivalent in Celsius, using the formula:
°C = 5/9 (° F - 32)

Compile and run the program. Its behavior should resemble this:
Temperature in Fahrenheit: 41
41 degrees Fahrenheit = 5 degrees Celsius

4. Create a class to find the sum of two numbers. This includes two data members, three member functions to input , output the data members and to find the sum of two data members.

5. Create a class to find the multiplication of two matrices. This include three data members of type arrays, three member functions, one is to accept two matrices, other to display two matrices and 3rd one is to find the multiplication of two matrices and display the result.

6. Create a class time with data members to store hours, minutes and seconds. WAP to input two times and find their sum.

7. Implement a class “number” having data members value and include following member functions
(i) IsEven()->Checks whether the value is even or odd
(ii) Findfactorial()->to calculate the factorial of the number

Saturday, January 17, 2009