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

11.

Write the definition of a function Reverse(int Arr[], int N) in C++, which should reverse the entire content of the array Arr having N elements, without using any other array.

Example: if the array Arr contains

13 10 15 20 5

Then the array should become

5 20 15 10 13

NOTE:

  • The function should only rearrange the content of the array.
  • The function should not copy the reversed content in another array.
  • The function should not display the content of the array.


void printarray(int arr[], int count)
{
	for(int i = 0; i < count; ++i)
		cout<<arr[i]<<' ';
	cout<<'\n';
}

void reverse(int arr[], int count)
{
	int temp;
	for (int i = 0; i < count/2; ++i)
	{
		temp = arr[i];
		arr[i] = arr[count-i-1];
		arr[count-i-1] = temp;
	}
}
 
int main ()
{  
	clrscr();
	const int SIZE = 10;
	int arr [SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	cout<<'Input Array\n';
	printarray(arr, SIZE);
	reverse(arr, SIZE);
	cout<<'Reverse Array\n';
	printarray(arr, SIZE);
	getch();
}
298 Views

Advertisement
12.

Write a definition for a function ADDMIDROW(int MAT[][10], int R, int C) in C++, which finds sum of the middle row elements of the matrix MAT (Assuming C represents the number of Columns and R represents the number of rows, which is an odd integer).
For example, if the content of array MAT having R as 3 and C as 5 is as follows:

1 2 3 4 5
2 1 3 4 5
3 4 1 2 5

The function should calculate the sum and display the following:
Sum of Middle Row: 15

157 Views

13.

T[25][30] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element T[10][15], if the element T[5][10] is stored at the memory location 25000.

108 Views

14.

Write the definition of a member function ADDMEM() for a class QUEUE in C++, to add a MEMBER in a dynamically allocated Queue of Members considering the following code is already written as a part of the program.

struct Member
{
	int MNO;
	char MNAME[20];
	Member *Next; 
};
class QUEUE
{
	Member *Rear,*Front;
public:
	QUEUE(){Rear=NULL;Front=NULL;}
	void ADDMEM();
	void REMOVEMEM();
	~QUEUE();
};
159 Views

Advertisement
15.

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
P + ( Q - R ) * S / T

244 Views

16.

Aditi has used a text editing software to type some text. After saving the article as WORDS.TXT, she realised that she has wrongly typed alphabet 'J' in place of the alphabet 'I' everywhere in the article.
Write a function definition for JTOI() in C++ that would display the corrected version of the entire content of the file WORDS.TXT with all the alphabets 'J' to be displayed as an alphabet 'I' on screen.
Note: Assuming that WORD.TXT does not contain any J alphabet otherwise.
Example: If Aditi has stored the following content in the file 'WORDS.TXT':

'WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE'

The function JTOI() should display the following content:

'WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A SENTENCE'

182 Views

17.

Write a definition for function COUNTDEPT( ) in C++ to read each object of a binary file TEACHERS.DAT, find and display the total number of teachers in the department MATHS. Assume that the file TEACHERS.DAT is created with the help of objects of class TEACHERS, which is defined below:

class TEACHERS
{
	int TID; char DEPT[20];
public:
	void GET()
	{
		cin>>TID;gets(DEPT);
	}
	void SHOW()
	{
		cout<<TID<<":"<<DEPT<<endl;
	}
	char *RDEPT(){return DEPT;}
};
133 Views

18.

Find the output of the following C++ code considering that the binary file BOOK.DAT exists on the hard disk with a data of 200 books.

class BOOK
{
	int BID;char BName[20];
public:
	void Enter();void Display();
};

void main()
{
	fstream InFile;
	InFile.open("BOOK.DAT",ios::binary|ios::in);
	BOOK B;
	InFile.seekg(5*sizeof(B));
	InFile.read((char*)&B, sizeof(B));
	cout<<"Book Number:"<<InFile.tellg()/sizeof(B) + 1;
	InFile.seekg(0,ios::end);
	cout<<" of "<<InFile.tellg()/sizeof(B)<<endl;
	InFile.close();
}
319 Views

Advertisement
Advertisement