kvsroernakulam.nic.in Class XII Computer Science Sample Question Paper : Kendriya Vidyalaya Sangathan
Name of the Organisation : Kendriya Vidyalaya Sangathan, Ernakulam
Class : Class XII
Year : 2012-13
Subject : Computer Science
Document Type : Sample Question Paper
Website : https://roernakulam.kvs.gov.in/
Download Question Paper :
Sample Paper1 : https://www.pdfquestion.in/uploads/22187-Computer1.pdf
Sample Paper2 : https://www.pdfquestion.in/uploads/22187-Computer2.pdf
Sample Paper3 : https://www.pdfquestion.in/uploads/22187-Computer3.pdf
Computer Science Sample Question Paper :
General Instructions :
(i) All questions are compulsory
(ii) Programming Language : C++
Related : Kendriya Vidyalaya Sangathan Class XII Physics Sample Question Paper : www.pdfquestion.in/22180.html
1. (a) When a function is overloaded, there are multiple definitions of the functions. What makes the various definitions of the function different from each other?
(b) Which C++ header file(s) will be essentially required to run/execute the following C++ code?
void main()
{
int Rno=465;
char SName[]= “Ajay Bhaskar”;
cout<<setw(6) <<Rno<<setw(25)<<SName<<endl;
}
(c) Rewrite the following program after removing the syntactical errors (if any). Underline each correction.
#include<iostream.h>
struct Screen
{ int C, R;}
void ShowPoint(Screen P)
{
cout<<P.C, P.R<<endl;
}
void main()
{
Screen Point1 = (5, 3);
ShowPoint(Point1);
Screen Point2= point1;
C.Point1+= 2;
Point1.R = Point1.R + 2;
}
(d) Find the output of the following program :
#include<iostream.h>
void ChangetheContent(int Arr[], int Count)
{
for(int C=0; C<Count; C++)
Arr[C]= Arr[Count – C- 1];
}
void main()
{
int A[]= {1, 2, 3}, B[] = {20, 30, 40, 50}, C[]= {100, 200};
ChangetheContent(A,3);
ChangetheContent(B,4);
ChangetheContent(C,2);
for(int L=0; L<3; L++) cout<<A[L]<<’#’;
cout<<endl;
for(int L=0; L<4; L++) cout<<B[L]<<’#’;
cout<<endl;
for(int L=0; L<2; L++) cout<<C[L]<<’#’;
cout<<endl;
}
(e) Give the output of the following program (Assuming that all required header files are included in the program)
void main()
{
char a[]= “Exam-2011 AheAd”;
int i;
for(i=0; a[i]!= ‘\0’;i++)
{
if(a[i]>= 97 && a[i]<=122)
a[i] –;
else
if(a[i]>= ‘0’ && a[i]<= ‘9’)
a[i] = a[i -1];
else
if(a[i]>= ‘A’ && a[i]<= ‘Z’)
a[i]+ = 32;
else
a[i]= ‘#’;
}
puts(a);
}
(f) Study the following program and select the possible output from it :
#include<iostream.h>
#include<stdlib.h>
const int LIMIT = 4;
void main()
{
randomize();
int Points;
Points= 100 + random(LIMIT);
for(int P=Points; P>=100; P–)
cout<<P<<’#’;
cout<<endl;
}
(i) 103#102#101#100#
(ii) 100#101#102#103#
(iii)104#103#102#101#
(iv) 103#102#101#100
2 (a) What is copy constructor and parameterized constructor? Illustrate with an example.
(b) Answer the questions (i) and (ii) after going through the following class :
class mammal{
public :
char category[20];
mammal( char xname[]) // function1
{
strcpy(category, xname)
}
mammal(mammal &t); //function2
};
(i) Create an object, such that it invokesfunction1.
(ii) Write complete definition for function2.
(c) Define a class Sports in C++ with following descriptions :
Private members :
** S_Code of type long
** S_Name of type character array (String)
** Fees of type integer
** Duration of type integer
Public members :
** Constructor to assign initial values of S_Code as 1001, S_Name as “Cricket”, Fees as 500, Duration 70
** A function NewSports() which allows user to enter S_Code, S_Name and Duration.
(d) Consider the following declarations and answer the questions given below :
class NATION
{
int H;
protected :
int S;
public :
void INPUT();
void OUTPUT();
};
class WORLD : private NATION
{
int T;
protected :
int U;
public :
void INDATA(int, int);
void OUTDATA();
};
class STATE : public WORLD
{
int M;
public :
void DISPLAY(void);
};
(i) Name the base class and derived class of the class WORLD.
(ii) Name the data member(s) that can accessed from function DISPLAY ().
(iii)Name the member function(s) which can be accessed from the objects of class STATE.
(iv) Is the member function OUTPUT() accessible by the objects of the class WORLD.
3 (a) Consider the following structure :
struct Employee
{
int ECode;
char Ename[20];
};
Write a function to accept an Employee array and perform insertion sort in the increasing order of ECode.
(b) An array MAT[10[11] is stored in the memory column wise with each element occupying 4 bytes of memory. Find out the base address and the address of element MAT[5][10], if the location of MAT[1][4] is stored at the address 2000.
(c) Give the necessary declaration of a linked list implementation queue containing integer type elements. Also write a user defined function in C++ to delete an integer type number from the queue.
(d) Write a function in C++ to print the sum of all the non-negative elements present on either diagonal of a two dimensional array passed as the argument to the function.
(e) Evaluate the following postfix expression using a stack and show the contents of the stack after each operation. 100, 40, 8, +, 20, 10, -, +, *
4(a) Observe the program segment given below carefully and fill the blanks marked in statement 1 using seekg( ) or seekp( ) functions for performing the required task.
#include<fstream.h>
class FILE
{ int Num;
(1)
char Name[30];
public :
void GO_Record(int); }; //function to read Nth record from the file
void FILE::GO_Record(int N)
{
FILE Rec;
Fstream File;
File.open(“STOCK”,ios::binary|ios::in);
File.read((char*)&Rec,sizeof(Rec));
cout<<Rec.Num<<Rec.Name<<endl;
File.close( );
}
(b) Write a function to count and print the number of complete words as “to” and “are” stored in a text file “ESSAY.TXT”.
void CWORDS( )
{ ifstream fin(“ESSAY.TXT”);
char st[80];
int count=0;
while(!fin.eof())
{
fin>>st;
if(!fin)
break;
if(strcmpi(st,”to”) = =0 || strcmpi(st,”are”)= =0)
count++;
}
cout<<”\nTotal ‘to’ & ‘are’ words = “<<count;
fin.close( ); }
(c) Write a function in C++ to display object from the binary file “PRODUCT.Dat” whose product price is more than Rs 200. Assuming that binary file is containing the objects of the following class :
class PRODUCT
{
int PRODUCT_no;
char PRODUCT_name[20];
float PRODUCT_price;
public :
void enter( )
{
cin>> PRODUCT_no ; gets(PRODUCT_name) ;
cin >> PRODUCT_price;
}
void display()
{
cout<< PRODUCT_no ; cout<<PRODUCT_name ;cout<< PRODUCT_price;
}
int ret_Price( )
{
return PRODUCT_price;
}
};