Computer Science
Class XII 2000(CBSE) You are on questions 1 to 3
Max Marks : 75 Time allowed : 3 hrs
Q 1.
(a) Illustrate the concept of function overloading with the help of an
example?
Q 1 (b) Name the header file, to which
following built-in function belong:
(i)isupper( ) (ii)setw( ) (iii)exp(
) (iv)strcmp( )
Q 1 (c) Will
the following program execute successfully? If not, state the
reason(s). #include<stdio.h> void main() { int
s1,s2,num; s1=s2=0; for(x=0;x<11;x++) { cin<<num;
if(num>0) s1+=num; else s2=/num;
} cout<<s1<<s2; }
Q 1 (d) Give the output of the following
program segment (Assuming all required header files are included in the
program): char *NAME="a
ProFiLe"; for(int
x=0;x<strlen(NAME);x++) if(islower(NAME[x])) NAME[x]=toupper(NAME[x]); else if(isupper(NAME[x])) if(x%2!=0) NAME[x]=tolower(NAME[x-1]); else NAME[x]--; cout<<NAME<<endl;
Q 1 (e) Write
the output of the following program: #include<iostream.h> int
func (int &x, int y=10) { if(x%y==0) return ++x; else return
y--; } void main(){ int
p=20,q=23; q=func(p,q); cout<<p<<q<<endl; p=func(q);
cout<<p<<q<<endl; q=func(p); cout<<p<<q<<endl; }
Q 1 (f) Write a function seqsum( ) in
C++ with two arguments, double x and int n. The function should return a
value of type double and it should find the sum of the following
series:
Q 2(a) Why is a destructor function required in classes? Illustrate with
the help of an example.
Q 2(b) Define a class worker with
the following specifications:
Private members of class
worker
wno |
integer |
wname |
25characters |
hrwrk,wgrate |
|
totwage |
|
calcwg(
) |
|
Public members
of the class worker
|
in_data(
) |
A function to
accept values for wno, wname,hrwrk,wgrateand invoke calcwg( ) to
calculate totpay. |
out_data( )
|
A function to
display all the data members on the screen.You should give
definitions of
functions. |
Q 2(c)Consider the following and answer the
following questions given below: class
School { int A; protected: int B,C; public: void
INPUT(int); void OUTPUT( ); } ; class Dept:protected
School { int X,Y; protected: void IN(int,
int); public: void OUT( ); }; class Teacher:public
Dept { int P; void DISPLAY(void); public: void ENTER(
); };
(i)Name the base class and derived class of the
class Dept. (ii) Name the data member(s) that can be accessed from
function OUT( ). (iii) Name the private member function(s) of class
Teacher. (iv) Is the member function OUT( ) accessible by the objects
of Dept?
Q
3. (a)Suppose A, B, C are arrays of
integers of size M, N and M+N respectively. The members in array A appear
in ascending order while the members in array B appear in descending
order. Write a user defined function in C++ to produce third array C by
merging arrays A and B in ascending order. Use A, B and C as arguments in
the function.
Q 3 (b) An array VAL[1……15][1……10] is stored
in the memory with each element requiring 4 bytes of storage. If the base
address of array VAL is 1500, determine the location of VAL[12][9] when
the array VAL is stored (i) Row wise (ii) Column wise.
Q 3 (c) Write a user-defined function in C++
to find and display the sum of both the diagonal elements of a two
dimensional array MATRIX[6][6] containing integers.
Q 3 (d) Evaluate the following postfix
expression using a stack. Show the contents of stack after execution of
each operation: 20, 8, 4, /, 2, 3, +, *, - (e) Give necessary
declaration for a queue containing float type numbers; also write a user
defined function in C++ to insert a float type number in the queue. You
should use linked representation of queue.
|