SAMPLE PAPER – 2013-14
COMPUTER SCIENCE (Theory)
CLASS – XII
Time allowed : 3 hoursMaximum marks : 70
Note :i)All the questions are compulsory .
ii)Programming Language : C++ .
- a) Whatis the difference between #defineconst ? Explain through example.2
b) Name the header files that shall be required for successful compilation of the following C++ program :1
main( )
{char str[20];
cout<fabs(-34.776);
cout<”\n Enter a string : ”;
cin.getline(str,20);
return 0; }
c) Rewrite the following program after removing all the syntactical errors underlining each correction. (if any)2
#include<iostream.h>
#include<stdio.h>
struct NUM
{ int x;
float y;
}*p;
void main( )
{
NUM A=(23,45.67);
p=A;
cout<”\n Integer = “<*p->x;
cout<”\n Real = “<*A.y;
}
d) Find the output of the following program segment ( Assuming that all required header files are included in the program ) : 3
void FUNC(int *a,int n)
{int i,j,temp,sm,pos;
for(i=0;i<n/2;i++)
for(j=0;j<(n/2)-1;j++)
if(*(a+j)>*(a+j+1))
{temp=*(a+j);
*(a+j)=*(a+j+1);
*(a+j+1)=temp;}
for(i=n-1;i>=n/2;i--)
{sm=*(a+i);
pos=i;
for(j=i-1;j>=n/2;j--)
if(*(a+j)<sm)
{pos=j;
sm=*(a+j);}
temp=*(a+i);
*(a+i)=*(a+pos);
*(a+pos)=temp; }}
void main()
{
int w[]={-4,6,1,-8,19,5},i;
FUNC(w,6);
for(i=0;i<6;i++)
cout<w[i]<' ';}
e) Give the output of the following program ( Assuming that all required header files are included in the program ) : 2
class state
{
private:
char *stname;
int size;
public:
state()
{ size=0;
stname=new char[size+1];}
state(char *s)
{size=strlen(s);
stname=new char[size+1];
strcpy(stname,s);}
void disp()
{cout<stname<endl;}
void repl(state &a, state &b)
{size=a.size+b.size;
delete stname;
stname=new char[size+1];
strcpy(stname,a.stname);
strcat(stname,b.stname); } };
void main()
{char *st1="Punjab";
clrscr();
state ob1(st1),ob2("Uttaranchal"),ob3("Madhyapradesh"),s1,s2;
s1.repl(ob1,ob2);
s2.repl(s1,ob3);
s1.disp();
s2.disp();getch();}
f) Observe the following program carefully & choose the correct possible output from the options (i) to (iv) justifying your answer. 2
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
randomize();
int RN;
RN=random(4)+5;
for(int i=1;i<=RN;i++)
cout<i<' ';
getch();}
i) 0 1 2ii)1 2 3 4 5 6 7 8iii) 4 5 6 7 8 9iv) 5 6 7 8 9 10 11 12
2. a) Differenciate between default parameterized constructor with suitable example.2
b) Answer the questions i) and ii) after going through the following class :2
#include<iostream.h>
#include<string.h>
#include<stdio.h>
class wholesale
{ char categ[20],item[30];
float pr;
int qty;
wholesale( )// Function 1
{ strcpy(categ ,”Food”);
strcpy(item,”Biscuits”);
pr=150.00;
qty=10 }
public :
void SHOW( )//Function 2
{
cout<categ<”#”<item<”:”<pr<”@”<qty<endl;
}
};
void main( )
{ wholesale ob;//Statement 1
ob.SHOW( );//Statement 2
}
i) Will statement 1 initialize all the data members for object obwith the values given in function 1?(Y/N). Justify your answer suggesting the corrections to be made in the above code.
ii) What shall be the possible output when the program gets executed? (Assuming, if required- the suggested correction(s) are made in the program.
c) Defne a class WEAR in C++ with following description :4
Private members :
codestring
Typestring
Sizeinteger
materialstring
Pricereal number
A function calprice( ) that calculates and assign the value of price as follows :
For the value of material as “WOOLEN”
TypePrice(Rs.)
------
Coat2400
Sweater1600
For material other than “WOOLEN” the above mentioned price gets reduced by 30%.
Public members :
A constructor to get initial values for code, Type & material as “EMPTY” & size and price with 0.
A function INWEAR( ) to input the values for all the data members except price which will be initialized by function calprice( ).
Function DISPWEAR( ) that shows all the contents of data members
d) Answer the questions (i) to (iv) based on the following :4
class COMP
{ private :
char Manufacturer [30];
char addr[15];
public:
toys( );
void RCOMP( );
void DCOMP( );
};
class TOY: publicCOMP
{ private:
char bcode[10];
public:
double cost_of_toy;
void RTOY ( );
void DTOY( );
};
class BUYER: publicTOY
{ private:
char nm[30];
char delivery date[10];
char *baddr;
public:
void RBUYER();
void DBUYER();
};
void main ( )
{ BUYER MyToy; }
i)Mention the member names that are accessible by MyToy declared in main() function.
ii)Name the data members which can be accessed by the functions of BUYER class.
iii)Name the members that can be accessed by function RTOY( ).
iv)How many bytes will be occupied by the objects of class BUYER?
3.a)Define a function that would accept a one dimensional integer array and its size. The function should reverse the contents of the array without using another array. (main( ) function is not required) 4
b) A two dimensional array A[15][25] having integers (long int), is stored in the memory along the column, find out the memory location for the element A[8][12], if an element A[10][6] isstored at the memory location 2800. 4
c) Evaluate the following postfix notation of expression :2
5, 8, 7, +, /, 7, *, 13, -
d) )Write a user defined function in C++ which accepts a squared integer matrix with odd dimensions (3*3, 5*5 …) & display the sum of the middle row & middle column elements. For ex. :
2572
37 2
56 9
The output should be :
Sum of middle row= 12
Sum of middle column = 18
e) Consider the following program for linked QUEUE :4
struct NODE
{ int x;
float y;
NODE *next;};
class QUEUE
{ NODE *R,*F;;
public :
QUEUE( )
{ R=NULL;
F=NULL;
}
void INSERT( );
void DELETE( );
void Show( );
~QUEUE( );};
Define INSERT( ) & DELETE( ) functions outside the class.
4. a) Observe the following program carefully and fill in the blanks using seekg( ) and tellg( ) functions : 1
#include<fstream.h>
class school
{ private :
char scode[10],sname[30];
float nofstu;
public:
void INPUT( );
void OUTPUT( );
int COUNTREC( ); };
int school::COUNTREC( )
{ fstream fin(“scool.dat”,ios::in|ios::binary);
______//statement 1
int B=______//statement 2
int C=B/sizeof(school);
fin.close( );
return C; }
b) Write a function in c++ to count the number of words starting with capital alphabet present in a text file DATA.TXT. 2
c) Write a function in c++ to add new objects at the bottom of binary file “FAN.DAT”, assuming the binary file is containing the objects of following class : 3
class FAN
{ private:
int srno;
char name[25];
float pr;
public:
void Enter( ){ cin>srno; gets(name); cin>pr;}
void Display( ){ cout<srno<namepr<endl;} };
5. a) What do you mean by degree & cardinality of a relation? Explain with example.2
b) Consider the tables FLIGHTSFARES. Write SQL commands for the statements (i) to (iv) and give the outputs for SQL queries (v) (vi) .
Table : FLIGHTS
FNO / SOURCE / DEST / NO_OF_FL / NO_OF_STOPIC301 / MUMBAI / BANGALORE / 3 / 2
IC799 / BANGALORE / KOLKATA / 8 / 3
MC101 / DELHI / VARANASI / 6 / 0
IC302 / MUMBAI / KOCHI / 1 / 4
AM812 / LUCKNOW / DELHI / 4 / 0
MU499 / DELHI / CHENNAI / 3 / 3
Table : FARES
FNO / AIRLINES / FARE / TAXIC301 / Indian Airlines / 9425 / 5%
IC799 / Spice Jet / 8846 / 10%
MC101 / Deccan Airlines / 4210 / 7%
IC302 / Jet Airways / 13894 / 5%
AM812 / Indian Airlines / 4500 / 6%
MU499 / Sahara / 12000 / 4%
i) Display flight number & number of flights from Mumbai from the table flights.1
ii) Arrange the contentsof the table flights in the descending order of destination.1
iii) Increase the tax by 2% for the flights starting from Delhi.1
iv) Display the flight number and fare to be paid for the flights from Mumbai to Kochi using the tables, Flights & Fares, where the fare to be paid =fare+fare*tax/100. 1
v) SELECT COUNT(DISTINCT SOURCE) FROM FLIGHTS;1
vi) SELECT FNO, NO_OF_FL, AIRLINES FROM FLIGHTS,FARES WHERE SOURCE=’DELHI’ AND FLIGHTS.FNO=FARES.FNO; 1
6. a) State and verify De Morgan’slaw.2
b) If F(A,B,C,D) = (0,1,2,4,5,7,8,10) , obtain the simplified form using K-Map. 3
c) Convert the following Boolean expression into its equivalent Canonical Sum of Products form (SOP) :2
(X+Y+Z) (X+Y+Z’) (X’+Y+Z) (X’+Y’+Z’)
d) Writethe equivalent Boolean Expression F for the following circuit diagram:1
7. a)What is a switch? How is it different from hub?1
b) What is the difference between optical fibrecoaxial transmission media.1
c)Define cookies & firewall.1
d) Expand WLLXML1
e)“Kanganalay Cosmetics” is planning to start their offices in four major cities in Uttar Pradesh to provide cosmetic product support in its retail fields. The company has planned to set up their offices in Lucknowat three different locations and have named them as “Head office”, “Sales office”, & “Prod office”. The company’s regional offices are located at Varanasi, KanpurSaharanpur. A rough layout of the same is as follows :
Approximate distances between these offices as per network survey team is as follows :
Place from / Place to / DistanceHead office / Sales office / 15 KM
Head office / Prod office / 8KM
Head office / Varanasi Office / 295 KM
Head office / Kanpur Office / 195 KM
Head office / Saharanpur office / 408 KM
Number of computers :
Head office / 156Sales office / 25
Prod office / 56
Varanasi Office / 85
Kanpur Office / 107
Saharanpur office / 105
i)Suggest the placement of the repeater with justification.1
ii)Name the branch where the server should be installed. Justify your answer.1
iii)Suggest the device to be procured by the company for connecting all the computers within each of its offices out of the following devices : 1
- Modem
- Telephone
- Switch/Hub
iv)The company is planning to link its head office situated in Lucknow with the office at Saharanpur. Suggest an economic way to connect it; the company is ready to compromise on the speed of connectivity. Justify your answer. 1
SAMPLE PAPER – 2013-14
COMPUTER SCIENCE (Theory)
CLASS – XII
Time allowed : 3 hoursMaximum marks : 70
Note :
i)All the questions are compulsory .
ii)Programming Language : C++ .
1.a) Differentiate between call by value & call by reference with suitable examples in reference to function. 2
b) Name the header files, to which the following built-in functions belong : 1
i) get( )ii) random( )
c) Will the following program execute successfully ? If no, state the reason(s) : 2
#include<iostream.h>
#include<stdio.h>
#define int M=3;
void main( )
{ const int s1=10;
int s2=100;
char ch;
getchar(ch);
s1=s2*M;
s1+M = s2;
cout<s1<s2 ;}
d) Give the output of the following program segment ( Assuming all required header files are included in the program ) : 2
int m=50;
void main( )
{
int m=25;
{ int m= 20*:: m;
cout<”m=”<m <endl;
cout<”::m=”< ::m <endl;
}
::m=++m+ m;
cout<”m=”<m <endl;
cout<”::m=”< ::m <endl;
}
e) Give the output of the following program : 3
#include<iostream.h>
double area(int l, double b)
{ return (l*b) ;}
float area(float b, float h)
{ return(0.5*b*h) ; }
void main( )
{ cout<area(5,5)<endl;
cout<area(4,3.2)<endl;
cout<area(6,3)<endl;
}
f) Observe the following program carefully & choose the correct possible output from the options (i) to (iv) justifying your answer. 2
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main( )
{
clrscr( );
randomize( );
int RN;
RN=random(4)+5;
for(int i=1;i<=RN;i++)
cout<i<' ';
getch(); }
i) 0 1 2ii)1 2 3 4 5 6 7 8iii) 4 5 6 7 8 9iv) 5 6 7 8 9 10 11 12
2. a) Define Multilevel & Multiple inheritance in context to OOP. Give suitable examples to illustrate the same. 2
b) Answer the questions (i) and (ii) after going through the following class : 2
class number
{ float M;
char str[25];
public:
number( )//constructor 1
{ M=0;
str=’\0’;}
number(number &t); //constructor 2
};
i) Write c++ statement such that it invokes constructor 1.
ii) Complete the definition for constructor 2.
b) A class TRAVEL with the following descriptions : 4
Private members are :
Tcode, no_of_pass, no_of_busesinteger (ranging from 0 to 55000)
Placestring
Public members are:
A constructor to assign initial values of Tcode as 101, Place as “Varanasi”, no_of_pass as 5, no_of_buses as 1.
A function INDETAILS( ) to input all information except no_of_buses according to the following rules :
Number of passengersNumber of buses
Less than 401
Equal to or more than 40 & less than 802
Equal to or more than 803
A function OUTDETAILS( ) to display all the information.
c) Answer the following questions (i) to (iv) based on the following code : 4
class DRUG
{ char catg[10];
char DOF[10], comp[20];
public:
DRUG( );
void endrug( );
void showdrug( );
};
class TABLET : public DRUG
{ protected:
char tname[30],volabel[20];
public:
TABLET( );
void entab( );
void showtab( );
};
class PAINKILLER : public TABLET
{ int dose, usedays;
char seffect[20];
public :
void entpain( );
void showpain( );
};
i)How many bytes will be required by an object of TABLET?
ii)Write names of all the member functions of class PAINKILLER.
iii)Write names off all members accessible from object of class PAINKILLER.
iv)Write names of all data members accessible from functions of class PAINKILLER.
3. a) Why are arrays called static data structure? 1
b) Given a two dimensional array AR[5][10], base address of AR being 1000 and width of each element is 8 bytes. Find the location of AR[3][6] when the array is stored as a) Column wise b) Row wise . 3
c) Convert the following infix notation into postfix expression : 2
(A+B)*C-D/E*F
d) Write a user defined function in C++ to find and display the column sums of a two dimensional array MAT[7][7]. 2
e) Give necessary declarations for a queue containing name and float type number ; also write a user defined function in C++ to insert and delete a node from the queue. You should use linked representation of queue. 4
f) Write a C++ function to sort an array having N integers in descending order using insertion sort method. 3
g) What are the precondition(s) for Binary Search ? 1
4. a) Observe the program segment given below carefully and answer the question that follows : 1
class school
{ private :
char name[25];
int numstu;
public:
void inschool( );
void outschool( );
int retnumstu( )
{ return numstu; }
};
void modify(school A)
{ fstream INOUT;
INOUT.open(“school.dat”,ios::binary|ios::in|ios::ate);
school B;
int recread=0, found=0;
while(!found & INOUT.read((char*)&B,sizeof(B))
{ recread++;
if(A.retnumstu( )= = B.retnumstu( ))
{
______//missing statement
INOUT.write((char*)&A,sizeof(A));
Found=1;
}
else
INOUT.write((char*)&B,sizeof(B));
}
if(!found)
cout<”\nRecord for modification does not exist”;
INOUT.close( );}
If the function modify( ) is supposed to modify a record in file school.dat with the values of school A passed to its argument, write the appropriate statement for missing statement using seekp( ) or seekg( ), whichever needed, in the above code that would write the modified record at its proper place.
b) Write a function in c++ to add new objects at the bottom of a binary file “STU.DAT”, assuming that the binary file is containing the objects of the following class : 3
class STUDENT
{ int rno;
char Name[25];
public:
void Enter( ){ cin>rno; gets(Name);}
void Display( ){ cout<rno<Name<endl;}
int retrno( ) {return rno;} };
c) Write a function in c++ to count & display the number of lines not starting with ‘A’ present in a text file “PARA.TXT”. 2
5. a) What do you understand by the terms Candidate key and Cardinality of a relation? 2
b) Write SQL commands for (i) to (vii) on the basis of the table LAB
Table : LAB
NO
ITEM NAMECOSTQTYDATEOFPURCHASEWARRANTYOPERATIONAL
1.COMPUTER45000921/5/9627
2.PRINTER15000321/5/9742
3.SCANNER21000129/8/9831
4.CAMERA 12000213/6/9612
5.HUB4000131/10/9921
6.UPS5000521/5/9614
7.PLOTTER13000211/1/200022
i) to select the item name purchased after 31/10/97. 1
ii) to list item name, which are within the warranty period till present date 1
iii) to list the name in ascending order of the date of purchase where quantity is more than 3. 1
iv) to count the number of items whose cost is more than 10000. 1
v) Give the output of the following SQL commands : 2
a) SELECT MIN(DISTINCT QTY) FROM LAB;
b) SELECT MIN(WARRANTY) FROM LAB WHERE QTY=2 ;
c) SELECT SUM(COST) FROM LAB WHERE QTY>2 ;
d) SELECT AVG(COST) FROM LAB WHERE DATEOFPURCHASE<{1/1/99} ;
6. a) State De’Morgans law and verify one of the laws using truth table . 2
b) If F(w,x,y,z) = (0,2,4,5,7,8,10,12,13,15) , obtain the simplified form using K-Map. 3
c) Represent AND using NOR gate(s). 1
d) Write the POS form of a Boolean function G, which is represented in a truth table as follows :
1
PQRG
0000
0010
0101
0110
1001
1010
1101
1111
e) Write the equivalent Boolean Expression for the following logic circuit : 1
7. a) What are routers? 1
b) Expand SMSC, DHTML. 1
c) What are backbone networks? 1
d) What do you mean by twisted pair cable? Write its advantages & disadvantages. .(any two) 1
e) Sunbeam Group of Institutions in Varanasi is setting up the network among its different branches. There are four branches named as Bhagwanpur (BGN), Lahartara (LHT), Varuna (V) and Annapurna (A). Distance between various branches are given below :
Branch BGN to V7 Km
Branch V to LHT4 Km
Branch V to A3 Km
Branch BGN to LHT4 Km
Branch BGN to A3.5 km
Branch LHT to A1 km
Number of computers :
Branch BGN 137
Branch V 65
Branch A29
Branch LHT98
i)Suggest a suitable topology for networking the computer of all the branches. 1
ii)Name the branch where the server should be installed. Justify your answer. 1
iii)Suggest the placement of hub or switches in the network. 1
iv)Mention any economic way to provide internet accessibility to all branches. 1
Work very hard & do the best in Board Exam!!!!!
SAMPLE PAPER – 2013-14
CLASS – XII
Time allowed: 3 hr. COMPUTER SCIENCE MM: 70
1. (a) “While implementing encapsulation, abstraction is also implemented”. Comment 2
(b) Name the header file to which the following functions belong: 1
(i) itoa()(ii) getc()
(c) Rewrite the following program after removing the syntactical errors (if any).Underline each correction: 2
class ABC
{int x=10;
float y;
ABC() {y=10; }
~() {}
}
void main()
{
ABC a1(10);
}
(d) Write the output of the following program :3
#include <iostream.h>
#include <string.h>
#include <ctype.h>
void swap(char &c1,char &c2)
{char temp;
temp=c1;
c1=c2;
c2=temp;
}
void update(char *str)
{
int k,j,l1,l2;
l1 = (strlen(str)+1)/2;
l2=strlen(str);
for(k=0,j=l1-1;k<j;k++,j--)
{
if(islower(str[k]))
swap(str[k],str[j]);
}
for(k=l1,j=l2-1;k<j;k++,j--)
{
if(isupper(str[k]))
swap(str[k],str[j]);
}
}
void main()
{
char data[100]={"bEsTOfLUck"};
cout<"Original Data : "<data<endl;
update(data);
cout<"Updated Data "<data;
}
(e) In the following program, find the correct possible output(s) from the options and justify your answer: 2
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
struct card { char suit[10];
int digit;
};
card* cards = new card[52]; // Allocate Memory
void createdeck()
{char temp[][10] = {"Clubs","Spades","Diamonds","Hearts"};
int i,m=0,cnt=1;
for(i=1;i<=52;i++)
{strcpy(cards[i].suit,temp[m]);
cards[i].digit=cnt;
cnt++;
if(i % 13 == 0)
{ m++;cnt=1; }
}
}
card drawcard(int num)
{int rndnum;
randomize();
rndnum = random(num)+1;
return (cards[rndnum]);
}
void main()
{createdeck();
card c;
c = drawcard(39);
if(c.digit > 10 || c.digit == 1)
{
switch(c.digit)
{case 11:cout<"Jack of "; break;
case 12:cout<"Queen of "; break;
case 13:cout<"King of "; break;
case 1:cout<"Ace of ";
}
}
else
cout<c.digit<" of ";
cout<c.suit;
delete[] cards; //Deallocate memory
}
Outputs:
i) Kind of Spadesii)Ace of Clubs
iii) Ace of Diamondiv)Queen of Hearts
(f) Give the output of the following program code: 2
#include <iostream.h>
strcut Pixel
{
int c,r;
};
void display(Pixel p)
{
cout<”Col “<p.c<” Row “<p.r<endl;
}
void main()
{
Pixel x = = {40,50}, y, z;
z= x;
x.c = x.c + 10;
y = z;
y.c = y.c + ;
y.r = y.r + 20;
z.c = z.c 15;
display(x);
display(y);
display(z);
}
2.(a) How does the visibility mode control the access of members in the derived class? Explain with example. 2
(b) Answer the questions (i) and (ii) after going through the following class: 2
class player
{
int health;