You are on page 1of 3

KENDRIYA VIDYALAYA NHPC SAINJ,KULLU

UNIT TEST NO : 1

MM : 40 TIME: 01:30hrs
Note: All the questions are compulsory.

Q No 1: Differentiate between an identifier and keywords. 1

Q No 2: Write the name of the header file to which the following belongs. 2

(i) abs() (ii) isalpha () (iii) puts() (iv) setw()

Q No 3: Write the name of the header file to which the following belongs. 2

(i) random() (ii) rand () (iii) getw() (iv) setw()

Q no 4: Write the name of the header files, which is/are essentially required to run/execute the

following C++ code. 2

void main()

char CH ,Text[]=“ +ve Attitude”;

for(int i=0;Text[ip!=’\0’,i++)

if(text[i]==’ ‘)

cout<<endl;

else

CH= toupper(text[i]);

cout<<CH; }

Q No 5: What will be the output of the following code fragment produce ?


i) 2
int val, res, n=1000;
cin>>val;
res = n +val >1750 > 400:200; cout<< res;

ii) 1

int ch=20; cout<<ch<<++ch;

iii) 2

#include<iostream.h>

int main()
{ int f=1,i=2;

Do { f *=I;

}while( ++I <5);

cout<<f;

return 0;

Q No 6: Define a class Serial in C++ with the following specifications: 4

Private members of class serial

Serialcode integer Title 20 characters Duration float

Noofepisodes integer

Public members of the class Serial

(i) A constructor function to initialize Duration as 30 and noofepisodes as 10.

(ii) Newserial () function to accept values for Serialcode and Title

(iii) Otherentries () function to assign the values of Duration and Noofepisodes with the
help of cin statement.

(iv) Dispdata () function to display all the data members on the screen.

Q No 7: Answer the questions (i) to (iv) based on the following : 4

class WORLD

{ private :
float A;
protected :

char B[20]; int C;

public:

void READ( ); void WRITE( );

};
class COUNTRY: public WORLD

{ long double D;

protected: long E;

public:

void INPUT( ); void OUTPUT( );

};
class STATE : private COUNTRY

{ private:
short F;
public:
void INSTATE( ); void OUTSTATE( ); };

i) Which type of inheritance has been illustrated in the above code.


ii) Name the data members which can be accessed by the objects of STATE class.
iii) Name the member functions that can be accessed by the objects of STATE class.
iv) How many bytes will be occupied by an object of class STATE?

Q No 8: What is the difference between constructor and destructor ? Give example of both. 4

Q No 9: Rewrite the following program after removing the systactical error(s) if any. 4

include <iostream.h>

Vid main()

float p1,p2,num;

p1=p2=0;

for(int x=0;x<11;x++)

{ cin<<num;

if(num>0) p1 += num;

else

p2 /= num; }

cout<<p1>>p2;

Q No 6: Explain the following terms briefly. 2 * 4 = 8;

(i) Abstract class (ii) Concrete class (iii) Polymorphism (iv) Encapsulation

Q No 7: What is the difference between Type casting and automatic type conversion? Also give a

suitable C++ code to illustrate both. 4

You might also like