KENDRIYA VIDYALAYA BEG, PUNE – 06

Subject :- Computer ScienceMax. Marks – 40

Class :- XITime – 90 Mins

Q1. (a) What is Actual parameter and formal parameter in c++?2

(b) Name the header files that shall be needed for the following code:-1

void main()

{

char string[]=”peace”

coutsetw(20)<string;

}

(c) Find the output of the following program:-3

#include<iostream.h

#include<ctype.h

void main()

{

char text{}=”Mind@work!”;

for (int I=0;Text[I] !=’\0’;I++)

{

if (!isalpha(Text[I]))

Text[I]=’*’;

else if (isupper(Text[I]))

Text[I]=Text[I]+1;

else

Text[I]=Text[I+1];

}

cout<Text;

}

(d) In the following program ,if the value of N given by the user is 30,what maximum and

minimum values the program could possible display?2

#include<iostream.h

#include<stdlib.h

void main()

{

intN,guessnum;

randomize();

cin>N;

guessnum=random(N-10) + 10;

coutguessnumendl;

}2

( e) Find out errors in the following program:-

class number

{int x=10;

float y;

number()

{ x=y=10;}

public:

number(number t)

{ x=t.x; y=t.y;

}

~ (){cout<"Object destroyed ";}

};

main()

{

number a1, a2(a1); }

Q2.(a) Define a class named Admission in C++ with following description?4

Private members:

admnointeger (Ranges 10-1500)

namestring of 20 characters

clsinteger

feesfloat

Public members:

A constructor which initialized admno with 10, name with “NULL”, cls with 0 & fees with 0

Function getdata() to read the object of Admission type.

Function putdata() to print the details of object of admission type.

Function draw_nos() to generate the admission no. randomly to match with admno and display the detail of object.

(b) Define a class teacher with the following specifications:4 Private members:
name:20 characters
sub:10 characters
basic,da,hra: integers
salary:float
calculate():that returns salary
public members:
readdata():read data values
showdata(): display details

(c)classtestmeout5

{ introllno;

public:

~testmeout()//Function 1

{coutrollno<” is Leaving examination hall”<endl;

}

testmeout()//Function 2

{ rollno=1;

coutrollno<” is appearing for examination “<endl;

}

testmeout(int n, char name[])//Function 3

{rollno=n;

cout<name<” is in examination hall”<endl;

}

testmeout(testmeout & t);//function 4

voidmywork()//Function 5

{coutrollno<” is attempting questions “<endl;

}

};

i) In object oriented programming, what is Function 1 referred as and when does it get invoked?

ii) Write a statement so that function 3 gets executed?

iii) What will be the output of the above code if its main function definition is as given below (assumed the definition of Function 4 is completed ) :

main()

{testmeout ob1;

ob1.mywork();

}

iv) Which feature of object oriented programming is demonstrated using Function 2, Function 3 and Function 4 in the above class testmeout?

v) What is the scope of data member (rollno) of class testmeout?

Q3 (a) Name the header files for functions : - 2

(i)strcpy( )(ii)setw( )

(iii)toupper( )(iv) puts( )

(b) Find the output of the following program:-3

#include<iostream.h

#include<ctype.h

void main()

{

char line{}=”Good@LOGIC!”;

for (int I=0;line[I] !=’\0’;I++)

{

if (!isalpha(line[I]))

line[I]=’$’;

else if (islower(line[I]))

line[I]=line[I]+1;

else

line[I]=line[I+1];

}

coutline;

}

(c) Find the output of the following program:-2

#include<iostream.h

void Execute (int & x, int &y = 200)

{

int temp = x+ y;

x+ = temp;

if (y != 200)

cout<,temp<,x<y<endl;

}

void main()

{

int A = 50, B = 20;

Execute (B);

cout< A<B<endl;

Execute(A,B);

cout < A < B < endl;

}

(d)Find the output of the following program:-2

#include<iostream.h

void main()

{

int A = 5, B = 10;

for (int I = 1; I <=2; I++)

{

cout <,” Line1” < A++< “&” < B-2<, endl;

cout <,” Line2” < ++B< “&” <A+3<, endl;

}

Q4) (a) Find the output of the following program :3

#include<iostream.h

void Indirect(int Temp=20)

{

for (int 1=10; I<=Temp; I+=5)

cout<I<” , “ ;

coutendl;

}

void Direct (intNum)

{

Num+=10;

Indirect(Num);

}

void main()

{

int Number=20;

Direct(Number) ;

Indirect();

cout< “ Number=” <Number<endl ;

}

(b) Answer the questions i) and ii)after going through the following class:2

class Science

{

char Topic[20];

int Weightage;

public:

Science()

{

strcpy(Topic,”optics”);

Weightage=30;

Cout<”Topic Activated”;

}

-Science()

{

cout<”Topic Deactivated”;

}

};

i) Name the specific features of class shown by Function 1 and Function 2in the

above example.

ii)How would function 1 and function 2 get executed ?

(c) What do you understand by function overloading? Give an example illustrating its use in a c++ program. 3

***************************** BEST OF LUCK ******************************