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

Interview questions

1. OOPS

OOPS Concepts-1

1.Describe the principles of OOPS
2.Explain the advantages of OOPs with the examples.
3.What are OOPS concepts? Explain with examples?
4.what do you mean by Generalization & realization in oops
5.What is method Overriding ? What is it in OOPS
6. What is method Overriding ? What is it in OOPS
7.what are the advantages of oops over traditional programming?
8.What are the advantages of inheritance?

Wednesday, January 14, 2009

OOPS ASSIGNMENT-2

Structure

1. Input student Name, Rollno, Branch, Age and telephoneno as a record through structure and display all the information.


2. Input Name, Degignation, Basic Salary of employee into the employee record and calculate

TA = 55% of Basic
DA = 65% of Basic
HRA = 35% of Basic
PF = 12% of Basic

Also calculate Group Salary and net salary

a) Use Array to structure to input minimum 3 records (3 persons data) and display all the records sequentially.
b Use pointer to structure to input minimum 3 records (3 persons data) and display all the records sequentially.


3. Input your date of Birth and current date through structure and calculate your age in Year, Month and days assume that 1 year = 365 days and 1 month = 30 days.

4. Create a student structure having data members roll, class & address, mark structure having data members roll, sub1, sub2, sub3 and a student detail structure having data members roll, class total marks, no of subject pass & overall pass. Those students who have appeared the exam, their information only stored in the mark structure array. Write a program which will collect the information & fill the data in student detail array depending on the pass criteria.

Saturday, January 10, 2009

OOPS ASSIGNMENT-1

Function and Array

1. WAP to swap two numbers using function.
2. WAP using function which outputs all the prime numbers between 2 and a given positive integer n:

Hint:
void Primes (unsigned int n);
A number is prime if it is only divisible by itself and 1.

3. WAP to define an enumeration called Month for the months of the year and use it to define a function which takes a month as argument and returns it as a constant string.

4. WAP to define a recursive version of the Power function

5. WAP to write a function which returns the sum of a list of real values

Hint:
double Sum (int n, double val ...);
where n denotes the number of values in the list.

6. The following table specifies the major contents of four brands of breakfast cereals.

Define a two-dimensional array to capture this data:
------------Fiber ----Sugar-----Fat------Salt
Top Flake--12g------25g -------16g-----0.4g
Cornabix---22g-------4g --------8g-----0.3g
Oatabix-----28g ------5g---------9g-----0.5g
Ultrabran---32g------7g---------2g------0.2g
Write a function which outputs this table element by element.