Subject

Computer and Communication Technology

Class

CBSE Class 12

Pre Boards

Practice to excel and get familiar with the paper pattern and the type of questions. Check you answers with answer keys provided.

Sample Papers

Download the PDF Sample Papers Free for off line practice and view the Solutions online.
Advertisement

 Multiple Choice QuestionsShort Answer Type

Advertisement
1.

Write the type of C++ tokens (keywords and user defined identifiers) from the following:
(i) new
(ii) While
(iii) case
(iv) Num_2

470 Views

2.

Anil typed the following C++ code and during compilation, he found three errors as follows:
(i) Function strlen should have prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
On asking, his teacher told him to include necessary header files in the code.Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following code.

{
	char Txt[] = "Welcome";
	for(int C= 0; C<strlen(Txt); C++)
		Txt[C] = Txt[C]+1;
	cout<<Txt<<endl;
}
132 Views

3.

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

void main()
{
	cout<<"Enter an Alphabet:";
	cin>>CH;
	switch(CH)
	case 'A' cout<<"Ant"; Break;
	case 'B' cout<<"Bear" ; Break;
}
125 Views

4.

Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
void main()
{
	int A,B,NUM[] = {10,23,14,54,32};
	for(int CNT =4; CNT>0; CNT--)
	{
		A=NUM[CNT];
		B=NUM[CNT-1];
		cout<<Diff(A,B)<<'#';
	}
}
184 Views

Advertisement
5.

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

void main()
{
	int *Point, Score[]={100,95,150,75,65,120};
	Point = Score;
	
	for(int L = 0; L<6; L++)
	{
		if((*Point)%10==0)
			*Point /= 2;
		else
			*Point -= 2;
		if((*Point)%5==0)
			*Point /= 5;
		Point++;
	}

	for(int L = 5; L>=0; L--){
		cout<<Score[L]<<"*";
	}
}
180 Views

6.

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum values that can be assigned to each of the variables N and M.

Note:
● Assume all the required header files are already being included in the code.
● The function random(n) generates an integer between 0 and n-1

void main()
{
	randomize();
	int N=random(3),M=random(4);
	int DOCK[3][3] = {{1,2,3},{2,3,4},{3,4,5}};
	for(int R=0; R<N; R++)
	{
		for(int C=0; C<M; C++)
			cout<<DOCK[R][C]<<' ';
		cout<<endl;
	}
}
(i)  (ii) 
1 2 3
2 3 4
3 4 5
1 2  3   
2 3  4
(iii) (iv)
1 2 
2 3
1 2 
2 3
3 4
236 Views

7.

Differentiate between private and public members of a class in the context of Object Oriented Programming. Also, give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.

99 Views

8.

Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.

class TEST
{
	long TCode;
	char TTitle[20];
	float Score;
public:
TEST()			//Member Function 1
{
	TCode=100;strcpy(TTitle,”FIRST Test”);Score=0;
}
TEST(TEST &T)      //Member Function 2
{
	TCode=E.TCode+1;
	strcpy(TTitle,T.TTitle);
	Score=T.Score;
}
};
void main()
{
_________________	//Statement 1
_________________	//Statement 2
}

(i) Which Object-Oriented Programming feature is illustrated by the Member Function 1 and Member Function 2 together in the class TEST?
(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively.

114 Views

Advertisement
9.

Write the definition of a class BOX in C++ with following description:

Private Members

- BoxNumber    // data member of integer type
- Side         // data member of float type
- Area         // data member of float type
- ExecArea()   // Member function to calculate and assign
               // Area as Side * Side

Public Members

- GetBox()     // A function to allow user to enter values of
               // BoxNumber and Side. Also, this
               // function should call ExecArea() to calculate
               // Area
- ShowBox()    // A function
               // and Area
108 Views

10.

Answer the questions (i) to (iv) based on the following:

class First
{
	int X1;
protected:
	float X2;
public:
	First();
	void Enter1(); void Display1();
};
class Second : private First
{
	int Y1;
protected:
	float Y2;
public:
	Second();
	void Enter2();
	void Display();
};
class Third : public Second
{
	int Z1;
public:
	Third();
	void Enter3();
	void Display();
};
void main()
{
Third T;       //Statement 1
__________;	//Statement 2
}

(i) Which type of Inheritance out of the following is illustrated in the above example?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance?

(ii) Write the names of all the member functions, which are directly accessible by the object T of class Third as declared in main() function.

(iii)Write Statement 2 to call function Display() of class Second from the object T of class Third.

(iv) What will be the order of execution of the constructors, when the object T of class Third is declared inside main()?



121 Views

Advertisement