How To Exam?

a knowledge trading engine...


Biju Patnaik University of Technology 2008-2nd Sem M.C.A Object Oriented Programming using C++ - Question Paper

Friday, 24 May 2013 07:45Web



Second Semester Examination - 2008

OBJECT ORIENTED PROGRAMMING USING C++

*<

J


Full Marks-70 Time: 3 Hours

Answer Question No. 1 which is compulsory and any five from the rest.

The figures in the right-hand margin indicate marks.

1. Answer the following questions : 2*10

(a)    How does a C++ structure differ from a C++ class ?

(b)    How dynamic initialization of objects are achieved ?

(c) What is the output from the following segment of C++ code :

int x = 5, y = 7, z = 1; cout z ++x y++;

(d)    What is a label in C++ ?

(e)    What are the two uses of & symbols in C++ ?

n F.AFRnwj.'incrcr*


(f)    What is a copy constructor ?

(g)    What is the difference between inheritance and composition ?

PS' *i J (h) What is the meaning of keyword this t united we staid... when used in the implementation of a

class member function ?

(i) What is the value in placing a class definition in a separate header file ?

(j) Create a program that prints out the first 500 even integers.

2. (a) When do we declare a member of class static ? What is a class ? How does it accomplish data hiding ?    3

(b) Suppose that a gas company charges the following rates, based on consumption :

Gas used

Rate

First 70 cubic meters

Rs. 50.00 fixed cost

Next 100 cubic meters

Rs. 5.00 per cubic meter

Next 230 cubic meters

Rs. 2.50 per cubic meter

Above 400 cubic meters

Rs. 1.50 per cubic meter

Write a C++ program that computes the charges for a given amount of gas usage. The program should continue to work until the user enters a negative number.

7

3. (a) Define a class to represent bank account with following members :    4

Data member:

Member function:

Account No.

PAN No.

Name of the account holder

Address

PIN

Email

Balance amount in the account

To assign initial values To deposit amount To withdraw an amount after confirming the opening balance display name, PAN no, and balance

(b) Define a class for a complex number. Write a program that computes sum of two complex number.    6

(a)    What do you mean by operator over loading ? State the rules for overloading operators.    4

(b)    The voltage gain of an amplifier is given by the formula

voltage _ gain =

275


>2 as/f


3z+<fl5/i

where f is the frequency in Hertz and n is the number of stages in the amplifier. Write a complete C++ program that asks the user to input values for n and f, calculates the value of the voltage gain using the formula, and produces the following display on the terminal screen : At a frequency of X hertz, the voltage gain is Y.

where X is replaced by the frequency and Y is replaced by the voltage gain.

6

5.    (a) How can error conditions that occur

during an objects creation be handled ? What are the issues associated with handling errors inside of constructors ?

4

(b) Write a program to print a table of values of the function y = e_x.    6

6.    Declare a C++ structure to contain the following five pieces of information about undergraduate students :

(1)    their first name

(2)    their last name

(3)    their Course Id

(4)    their current GPA, and

(5)    the branch of Engineering.

Using this structure, write a C++ function called Initialize which declares a data structure to store information for up to 100 students, and initialize each of the elements in this data structure to some default values.    10

7. Consider the following template class and answer the related questions below :

template ctypename T> class Array { public:

T* data; int length;

};

(a) Write a template function allocate that returns an Array <T> such that data points to an array of N elements and length is assigned to N. The allocate function should have just one parameter, the value of N.    2

(b)    Write a template function index that has two parameters, an Array <T> x, and an index k. The function should return x.data[k] when 0 < = k < x. length and should return an arbitrary object of type T if k is either negative or if k> = x.length. 2

(c)    Write a simple program that creates and Array<int> and calls both of your template functions.    6

8. (a) What is the difference among public, protected and private members of a class?

2.5

(b) Determine the exact output of the following:    2.5

void main()

{ int j, i;

for (i = 12; i >= 0; i = i - 4)

for (j = 1; j < 3; j ++) cout i-j

}

(c)    How is the un-subscripted name of a two-dimensional array interpreted in C++ ?

2.5

(d)    Rewrite the following code segment using awhile loop    2.5 int start, x, total = 0, finish = 100;

for (start = 0; start < = finish; start ++)

{

cin x; total += x; start ++;

}

PCS 2002    8    -C







Attachment:

( 0 Votes )

Add comment


Security code
Refresh

Earning:   Approval pending.
You are here: PAPER Biju Patnaik University of Technology 2008-2nd Sem M.C.A Object Oriented Programming using C++ - Question Paper