Monday, 21 December 2015

12TH CS IST PB QUESTION WITH ANSWER KEY 15-16






11th   and 12th  CS common assignment  year 2013 (Outside Delhi)

1(a)
WHAT IS THE BENEFIT OF USING DEFAULT PRAMETER/ARGUMENT IN A
FUNCTION? GIVA A  SUITABLE  EXAMPLE TO ILLUSTRATE IT USING A C++ CODE.
2
ANS
Default parameter allows programmer to assign a value to the formal parameter , which gets substituted  in absence of corresponding actual parameter .

Void calc(int  A=900)
{
  Cout<<100*A<<”\n”;
}
Void main()
{
Calc(100);
Calc();
}


(b)
OBSERVE THE FOLLOWING C++ CODE AND WRITE THE NAME()S OF THE HEADER   FILES(S), WHICH WILL ESSENTIALLY REQUIRED TO RUN IT IN A C++ COMPILER:

Void  main()
{
 Float Area,Side;
Cin>>Area;
Side=sqrt(Area);
Cout<<”ONE  SIDE  OF THE SQUARE IS :”<<Side<<endl;
}
1
ANS
iostream.h/iomanip.h/fstream.h/math.h/stdlib.h

(c)

OBSERVE THE FOLLOWING C++ CODE CAREFULLY AND REWRITE THE SAME AFTER REMOVINGALL THE SYNTAX ERROR(S) PRESENT IN THE CODE . ENSURE THAT YOU  UNDERLINE EACH CORRECTION IN THE CODE.

IMPORTANT  NOTE :
-          ALL THE DESIRED HEADER FILES ARE ALREADY INCLUDED , WHICH ARE REQUIRED TO RUN THE CODE
-          CORRECTION SHOULD NOT CHANGE THE LOGIC OF THE PROGRAM






#define Change(A,B)      2*A+B;
void main()
{
Float X,Y,F;
Cin>>X>>Y;
F=Change[X.Y];
Cout<<”Result:”<<F<endline;
}




ANS
#define Change(A,B)      2*A+B;
Void main()
{
float X,Y,F;                                                     // F - uppercase
Cin>>X>>Y;
F=Change(X.Y);                                            //wrong brase
Cout<<”Result:”<<F<<endl;                   //endline should be – endl
                                                                   // single < with cout
}                                                                        


(f)
BASED ON THE FOLLOWING C++ PROGRAM  ,FIND OUT THE EXPECTED CORRECT OUTPUT(S) FROM THE OPTIONS (I) TO (IV) . ALSO FIND OUT THE MAXIMUMAND THE MINIMUMTHAT CAN BE ASSIGNEDTO THE VARIABLE
GUESS USED IN THE CODE AT THE TIME WHEN VALUE OF TURN IS 3.


void main()
{
   Char result [] [10] ={“GOLD” , “SILVER” , “BRONZE”};
    Int Getit=9, Guess;
    for (int Turn = 1;Turn<4;Turn++)
     {
             Guess=random(Turn);
           cout<< Getit-Guess<< Resut [Guess]<<”*”;
      }
}


(i)                   9Gold*9Gold*8Silver*
(ii)                9Gold*7Bronze*8Gold*
(iii)               9Gold*8Silver*9Gold*
(iv)              9Gold*8Silver*8Gold*

ANS

EXPECTED CORRECT OUTPUTS ARE OPTIONS (I) AND (III)

WHEN TURN = 3:
MINIMUM VALUE OF GUESS  = 0
MAXIMUM VALUE OF GUESS  = 2





 



 KENDRIYA VIDYALAYA OCF AVADI, CHENNAI REGION

CLASS XII- IST PRE-BOARD EXAMINATION - 2015-16

COMPUTER SCIENCE(083)

ANSWER KEY(FOR REFERENCE TO STUDENTS)

Time Allowed: 3hrs                                                                                                  Maximum Marks: 70

Instructions:

(i)     All questions are compulsory.
(ii)   Programming language: C++

1.        (a) What do you understand by constant argument? Explain with example.                  -2

Ans.


Constant Argument











An  argument  declared  with  const




keyword in a function definition.

















Argument  must  be  passed  while




calling the function.











Argument   is   not   allowed   to   be




modified by the function.






























E.g:







void function(const int a, int b=20)




{







a = a + b ;  //error can not modify const a





cout<<b; 












}







void main()






{







int m;







m=10;







function(m);   //second argument not passed,
Will use default











}







1-mark for explanation







1-mark for correct example






(b)  Write the header files compulsory required to execute the following c++ code:
1



void main()
{

char name[40]; strcpy(name,"CBSE"); puts(Text);

}

Ans:

(i).string.h (ii). stdio.h

(1/2 marks for each)

(c)        Read the given C++ code carefully, and rewrite it after removing syntactical errors with each correction underlined:

void count_b_B(char str[30])

{

int i,count=0;

for(i=0; i!='\0' ; i++)

{

if(str[i]='b' && str[i]='B')

count + 1 ;

}

cout<<"Count = "<<count<<endl;

}

Ans:

void count_b_B(char str[30])

{

int I,count=0;

for(i=0; str[i]!=’\0’ ; i++)

{

if(str[i]==’a’ || str[i]==’A’)

count=count + 1 ;

}

cout<<”Count = “<<count<<endl;

}

½ marks for each correction (1/2 marks for both == correction)

(d)  Observe the following C++ code carefully and write the output:
3
 #include<iostream.h>
int x=15;

void callme(int a,int &b, int c=1)
{
x+=a;
x=a+c;
c++;
cout<<a<<','<<b<<','<<c<<endl;
}

void main()
{
int x=20, y=30;
callme(x,::x,y);
cout<<x<<','<<::x<<','<<y<<endl;
callme(::x,y);
}

Ans:

20,50,31
20,50,30
50,30,2

1-mark for each line of correct output

(e)  Observe the following C++ code carefully and write the output:
2

#include<iostream.h>
void main()
{
    int b[]={40,33,44,55,66},i=1;
              while( i++ < 5 )
             {
              b[i]%2!=0 ? cout<<b[i]<<'#' : cout<<b[i]<<endl;
              }
}




Ans:
44
55#66
8839#


1-mark for each line of correct output

(f)         Observe the given c++ code carefully and select the correct output out of options (i) to (iv), if the value of n is 4. Also justify your answer:                                                       -2

#include<iostream.h>

#include<stdlib.h>
 void main()

{

int n,x,i;

cout<<"Enter value of n: "; cin>>n;

randomize();

for(i=0;i<4;i++)

{
  x=random(n);
                      n--;
                      cout<<x<<':';


}


}



(i).
3:2:1:0:


(ii).
2:2:1:0:


(iii)        . 3:2:3:0:


(iv).
0:0:0:0:


Ans:



(i), (ii) and (iv)


Reason: Loop runs 4 times


1st time value of k(random(4)) can be between 0-3

2nd time value of k (random(3)) can be between 0-2

3rd time value of k (random(2)) can be between 0-1,





1-mark for correct option


1-mark for justification


2.  (a)  What do you mean by Data hiding and Data encapsulation.
2
Ans:



2-mark for correct definition




(b)  Given the following C++ code, answer (i) & (ii):
2
class Date


{




int dd,mm,yy;



public:



Date();
//function-1


Date(int,int,int);//function-2


Date(Date &d);
//funciton-3


void getDate();
//function-4


~Date();
//funciton-5

};




(i). Which function(s) will be invoked if the following statement is executed:
                       
Date d1; Date d2(d1);

(ii).  Define the coding of function-3 outside the class.

Ans:

(i). function-1 and function-3 (ii). Date::Date(Date &d) {dd=d.dd; mm=d.mm; yy=d.yy; }

(1-mark for each subdivision)

(c)  Define a class Ticket as per the given details:
4

Private Members:

To of type string (for storing destination city) From of type string (for storing start city) Distance of type integer.

Fare of type float. BasicFare of type float.

A function AssignFare() to assign the value of Fare as BaseFare + DistanceFare, where DistanceFare is calculated as per the distance and Rate per KM as given below:

Distance(in KM)
Rate/KM(in Rs)

<=500
30Rs/Km

>500 & <=1000
25 Rs/Km

>1000
15 Rs/Km

Public Members:


A function Input() to accept the values of all data members except Fare from

user and to call the function AssignFare() to calculate and assign value of Fare.

A function Output() to display all data members.

Ans:
1-mark for correct class syntax with correct data member declaration

1-mark for correct AssignFare() function

½ -mark for Input()


1-mark for Output()


 ½ mark for calling AssignFare() from Input() correctly.

(d)  Answer (i) to (iv) based on the given code:
4

class MNC

{

char Cname[20]; protected:

char Hoffice[20];
                    public:

MNC();

char Country[20];
void EnterData();
 void DisplayData();

};

class Branch : public MNC

{

int NOE;

char Country[20]; protected:

void Association();
                   public:

Branch();
void Add(); void Show();

};

class Outlet : public Branch

{

char State[20]; public:

Outlet();
void Enter();
void Output();

};

(i). Which type of inheritance is illustrated in the above C++ code?.

(ii).  How many bytes does an object belonging to class Outlet require?

(iii). Which one out of the following can not be accessed by the member function of class Outlet:

(a). State[ ]  (b). Association( )   (c). Hoffice[ ]  (d). Cname[ ]

(iv). Name the data member(s) which are accessible from the object of class Branch.

Ans:

                 (i)Multilevel     
(ii) 102 bytes (iii).Cname[]
(iv). Country[]

1-mark for each

3.        (a) Write a function Rearrange(int A[ ][30],int B[ ], int r,int c, int &s) in C++ which  should copy all the elements of 2-D array A into 1-D array B row wise. (Where r is row size, c is column size, and s is the number of elements in array B after copying the elements of A).                                                                                                                         -2

E.g. if the 2-d array A is

15
25
35
45




55
65
75
85




then the content of array B should be:

15
25
35
45
55
65
75
85








Ans:

void Rearrange(int A[ ][30],int B[ ], int r,int c, int &s)

{

int i,j,k; for(i=0,k=0;i<r;i++)

for(j=0;j<c;j++,k++) //1mark for correct loop B[k]=A[i][j]; //1/2 mark for correct assignment

s=k;      //1/2 mark (including function syntax & variables)

}

(b)    Write a function merge(?) in C++ which accepts two 1-D array and their sizes as arguments and copy the elements in a third 1-D array such that the first element is from first array, second element is from second array, third element is from first array, fourth element is from second array and so on. If any one of them is exhausted it should copy all the remaining elements of another array.                                                                                     -3                                                                                       

e.g. if the given array is 

10
17
15
13
12





and the second array is

20
25
29



then the resultant array should be:

10
20
17
25
15
29
13
12








Ans:
Correct logic for – 03 marks


(c)        An array DATA[1..10][1..10] requires 4 bytes for each element. If the base 3 address of the array is 1500, determine the location of DATA[4][5], when the array is row wise.

Row wise formula: (1/2 mark) &A[i][j]=BA+ES[(i-Lr)C + (j-Lc)]


(1/2 marks for correct identification of parameters and substitution) Lr=1 , Lc=1, Ur=10, Uc=10

I=4 , j=5 BA=1500 , ES=4

(1/2 mark for finding Column Size) Column size = Uc-Lc+1 = 10-1+1 = 10 C=10

(1.5 marks for correct calculation and answer)

&DATA[4][5] = 1500 + 4*[(4-1)*10 + (5-1) ] =1500 + 4 * 34 = 1500 + 136 = 1636

ANS = 1636

(d) Define function queue_del() to delete nodes, for a  linked list implemented queue having the following structure for each node:

struct node

{

char name[30];
char sex;
 int age;

node *Link;

};



Ans:


void queue::queue_del()

{

node *temp , *front;
node *rear;
if(front==NULL)

{

cout<<"Underflow.";

getch();

return;

}

temp=front; front=front->Link;
if(front == NULL)
rear = NULL;

cout<<"Following node is deleted:\n"; cout<<"Name: "<<temp->name<<endl;
cout<<”Sex:”<<temp->sex<<endl;
cout<<"Age: "<<temp->age<<endl;
delete temp;

}


(e)        Convert the following infix expression to its equivalent postfix expression 2 showing stack contents for the conversion:
                          
A + B * (C - D) / Z

Ans:  (A + B * (C - D) / Z)

Element
Stack
Output Expression



(
(




A
(
A



+
(+
A



B
(+
AB



*
(+*
AB



(
(+*(
AB



C
(+*(
ABC



-
(+*(-
ABC



D
(+*(-
ABCD



)
(+*
ABCD-



/
(+/
ABCD-*



E
(+/
ABCD-*Z



)

ABCD-*Z/+



ANS: ABCD-*Z/+

(1-mark for correct table) (1-mark for correct answer)

4. (a) Observe the given C++ code and write statement-1 & statement-2 to perform the 1 required task:

class score

{

char playername[30]; long score;

public:

void getscore(); void putscore();

};

void main()

{

ifstream file; file.open("file.dat",ios::in|ios::binary);
score s;

____________________//statement-1

____________________//statement-2
 s.putscore(); //displaying last record
file.close();

}

(i). Write statement-1 to place the get pointer/cursor at the beginning of last record.

(ii). Write statement-2 to read the record at current cursor position.
 Ans:

(i). file.seekg(-1*sizeof(s),ios::end); (ii). file.read((char*)&s,sizeof(s)); 1-mark for each

(b) Write a C++ function which opens a text file welcome.txt and displays the words starting with vowel  upper case.                                                                                                 -2        




1-mark for correctly open/close & loop

1-mark for correctly reading & checking 1st  char

(c)  A file ALLBOOKS.DAT contains the objects of class Book as given below:
3

enum bool {true,false}; class Book

{

int Bno;

char Btitle[40];
 bool issued;
          public:

bool isIssued()

{ return issued;  }

};

Write a C++ function to read from file ALLBOOKS.DAT and store all the books which have been issued in another file named ISSUED.DAT.


Ans:

void copy()

{

ifstream fin; ofstream fout;

fin.open("ALLBOOKS.DAT",ios::in|ios::binary);

fout.open("ISSUED.DAT",ios::out|ios::bianry);

if(!fin||!fout)

{

cout<<"file not opened."; getch();

return;

}

Book b; while(fin.read((char*)&b,sizeof(b)))

{

if(b.isIssued()==true)

fout.write((char*)&b,sizeof(b));

}

fin.close();

fout.close();

}

1-mark for correctly opening/closing both the files

1-mark for correct loop and reading

1-mark for correct checking and writing

5.        (a) Write the difference between a ALTER TABLE  and a INSERT command in DBMS with the help of  suitable example. 2

1-mark for explanation

1-mark for example

(b)  Consider the following tables SCHOOL and ADMIN. Write SQL commands for
6
the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).






SCHOOL





CODE
TEACHERNAME
SUBJECT

DOJ
PERIODS
EXPERIENCE















1001
RAVI SHANKAR
ENGLISH

12/03/2000
24

10















1009
SUJITH KUMAR
PHYSICS

03/09/1998
26

12















1203
LISA ANAND
ENGLISH

09/04/2000
29

5















1045
YASHRAJ
MATHS

24/08/2000
24

15















1123
KARTHIK
PHYSICS

16/07/1999
25

3















1167
EKTHA SHARMA
CHEMISTRY

19/10/1999
27

5















1215
UMESH
PHYSICS

11/05/1998
22

16


















ADMIN







CODE

GENDER


DESIGNATION

















1001

MALE

VICE PRINCIPAL

















1009

MALE

COORDINATOR

















1203

FEMALE

COORDINATOR


















1045

MALE

HOD


















1123

MALE

SENIOR TEACHER

















1167

FEMALE

SENIOR TEACHER


















1215

MALE

HOD




(i)     To display TEACHERNAME, PERIODS of all teachers whose periods less than 25.


      (ii) To display TEACHERNAME, CODE and DESIGNATION from tables

SCHOOL and ADMIN whose gender is male.

      (iii) To display  subject & the number of teachers in each subject.


       (iv) To display CODE, TEACHERNAME and SUBJECT of all teachers who have joined the school after 01/01/1999.

(v)   SELECT MAX(EXPERIENCE), SUBJECT FROM SCHOOL GROUP BY SUBJECT;


(vi)             SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN WHERE DESIGNATION = ‘COORDINATOR’ AND SCHOOL.CODE=ADMIN.CODE;


(vii)           SELECT DESIGNATION, COUNT (*) FROM ADMIN GROUP BY DESIGNATION HAVING COUNT (*) <2;


(viii)         SELECT COUNT (DISTINCT SUBJECT) FROM SCHOOL; Ans:



1-mark for each correct query



½ mark for each correct output

6.
(a)
State and prove Absorption  law.
2


X + X Y = X
X . (X + Y) = X
1-mark for  expression



1-mark for proof


(b)
Convert the following Boolean expression into its equivalent Canonical Product
1


of Sum form: X Y’ Z + X’ Y Z + X’ Y Z ‘




1-mark for correct result



(c)
Draw the logic circuit for the following boolean expression:
2










F ( X ,Y , Z ) = ( X + Y ).( X+ Z ).(Y+ Z )



2-marks for full correct



1-mark can be given for partial correct(with little errors)


(d)
Simplify the following boolean expression using K-map:
3


F ( A, B, C, D)=(0,2,3,4,6,7,8,10,12)



3 marks for full method and correct answer

7.
(a)
What is Twisted Pair cable?
1


1-mark for correct definition


(b)
What is the difference between IP Address and MAC Address?
1


1-mark for specific difference


(c)
Expand:   i) SMTP   ii) 4G
1


½ -mark for each expansion.


(d)
What is meant by the terms Hackers and Crackers?
1


1-mark for correct explanation


(e)


South and North Public Ltd has decided to network all its offices spread in five building as
4


shown below:




Building 2

Building 1
Building 3








Building 4                                       Building 5




The distance between various buildings is as follows:

Building 1 to Building 2
20m
Building 3 to Building 5
70m
Building 2 to Building 3
50m
Building 1 to Building 5
65m
Building 3 to Building 4
120m
Building 2 to Building 5
50m
Building 4 to Building 5
30m

Number of Computers in each building:

Building 1
40
Building 2
45
Building 3
110
Building 4
60
Building 5
70

(i)        Suggest a cable layout for connecting all the buildings together.

(ii)      Suggest the most suitable building to install the server of the organization with a suitable reason.

(iii)    Building 3 is used for many critical operations. It is tried that PC gets maximum possible bandwidth. Which network device is/should be used for this?


    (iv).The organization also has another office in same city but at a distant location


        about25-30 Km away. How can link be established with building 1. (Suggest the


        transmission media).


1-mark for each correct answer

(f)
What is meant by Wireless Technologies?
1

1-mark for correct answer

(g)
Explain the difference between Bus Topology and Star Topology.
1

1-mark for correct difference