# SAMPLE PAPER SET

Networking and Communications

Oct 26, 2013 (3 years and 1 month ago)

53 views

SAMPLE PAPER

SET

MARKING SCHEME

COMPUTER SCIENCE [CODE

083]

CLASS

XII

Max Time : 3 hours Max Marks : 70

1

(a) Write the prototype of a function named Percent, which takes an integer as value parameter and
return a float type value. Th
e parameter should have a default value 10.

Ans) float Percent(int a=10);

(b) Write the names of header files, which are
NOT
necessary to run the following program:

#include <iostream.h>

#include <stdio.h>

#include <string.h>

#include <math.h>

void main()

{

char STR[80];

gets(STR);

puts(strrev(STR));

}

Ans) 1. #include<math.h>

2. #include<iostream.h>

(c) Tarunaj

has just started working as programmer in the JAGAT WORLD SOFTWARE company.
In the company, he has got his first assignment to develop a small C++ module to find the
biggest number out of a given set of numbers stored in a one dimensional array. Somehow h
e
has committed a few logical mistakes while writing this code and so he is not getting the
desired result from the code. Find out the mistakes and correct this C++ code so that it provides
the desired result (do not add any new statement in the code). Und
erline each correction

int BIGFIND(int ARR[],int Size)

{ int BIG=ARR[1]; //Statement 1

for (int C=2;C<Size;C++) //Statement 2

if (ARR[C]<BIG) //Statement 3

ARR[C]=BIG; //Statement 4

return BIG; //Statement 5 }

Ans)
int BIGFIND(int ARR[],int

Size)

{

int BIG=ARR[0
]; //Statement 1

for (int C=
1
;C<Size;

C++) //Statement 2

if (ARR[C]>
BIG) //Statement 3

BIG
=
ARR[C]; //Statement 4

return BIG; //Statement 5

}

(d) Find output of the following program segment:

int A[][3] = {{1,2,3}, {5,6,7}};

for (int i = 1; i<2; i++)

for (int j = 0; j<3; j++)

cout<<A[i][j]<<"*
\
n";

Ans) 5*

6*

7*

(e) Find output of the following program
segment:

int a = 3;

void demo(int x, int y, int &z)

{ a += x+y;

z = a+y;

y += x;

cout<<x<<'*'<<y<<
'*'<<z<<endl;

}

void main()

(3)

{ int a = 2, b = 5;

demo(::a,a,b);

demo(::a,a,b);

}

Ans)

3*5*10

8*10*20

(f) Write a function in C++ to accept two integers as parameters and returns the greater of these

numbers.

Ans)

int max(int a,int

b)

{ int big;

if(a>b)

big=a;

else

big=b;

return
(
big
)
;

}

2. (a) What do you understand by Data Encapsulation and Data Hiding? Also,

give a suitable C++ code to illustrate both.

Ans)

Encapsulation
:
Wrapping up of data and member functions into

a single unit called class

Data hiding: It is a property that enforces only relevant information is exposed to the user and rest of the information is h
idden from
the user

Eg;

class student

{

private://data hiding

int a, b;

encapsulation

public:

void enter();

void disp()

};

(b) What is constructor overloading? Give an example to illustrate the same.

(2)

Ans
) A constructor name having several definitions that are differentiable by the number or type of

Eg

class sample

{int a,b;

sample()
//default constructor

{a=0;b=0;}

sample(int m,int n)
//parameterized
constructor

{a=m;b=n;}
};

c)
Define a class HandSet in C++ with following description:

Private members:

Make
-

of type string

Model
-

of type string

Price
-

of type long int

Rating
-

of type char

Public Members:

dSet type.

Function Display() to display the details of an object of HandSet type.

Function RetPrice() to return the value of Price of an object of HandSet type.

Ans)

class Handset{

char make[10],model[10],Rating;

long int price;

public:

);

void Display( );

long int RetPrice( )

{return price;}

};

{

gets(make); gets(Model);

cin>>Price; cin>>Rating;

}

void Handset::Display();

{

puts(make);Puts(Model);

cout<<Price<<Rating;

}

(d) Consider the following class
counter
:

class counter

{ protected :

unsigned int count;

public :

counter()

{ count = 0; }

void inc_count()

{ count++; }

int get_count()

{ return count; }

};

Write code in C++ to publically derive another class new_counter from class counter. Class
new_counter should have the following additional function members in the public visibility mode:

(i) A parameterized constructor to initialize the value of count to the value of parameter.

(ii) dec_count() to decrease the value of data member count by 1.

(iii) Reset() to set the value of data member count to 0.

Ans)

class new_counter : public counter

{

public:

new_counter(unsigned int a)

{ count = a; }

void dec_count()

{ count
--
; }

void Reset()

{ count = 0; }

};

Note: If
count is private,
the code should be

class new_counter:

public counter

{int x;

public:

newcounter(
unsigned
int a):counter(a)

{

}

void dec_count()

{count
--
;}

void Reset( )

{count=0;}

};

3
.

(a) Write a function TRANSFER(int A[], int B[], int

Size) in C++ to copy the elements of
array A into array B in such a way that all the negative elements of A appear in the
beginning of B, followed by all the positive elements, followed by all the zeroes
maintaining their respective orders in array A. For

example:

If the contents of array A are:

7,
-
23, 3, 0,
-
8,
-
3,4, 0

The contents of array B should be

-
23 ,
-
8,
-
3, 7, 3, 4, 0
,0

Ans)

void TRANSFER(int A[], int B[], int size)

{

int i, j = 0;

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

if (A[i] > 0)

{

B[j] = A[i];

j++;

}

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

if (A[i] < 0)

{

B[j] = A[i];

j++;

}

for (; j<size; j++)

B[j] = 0;

(b) Each element of the array A[8][6] is stored using 4 bytes of memory. If the element A[2][4]
is stored at location 936, find the addr
ess of A[5][1]. Assume that the array

Assume that the array is stored column
-
wise.

Ans)

W=4 , R=8, C=6

-
lr)+
R
(j
-
lc)))

936 = B+4(((2
-
0)+
8
(4
-
0)))

= B+4(3
4)

936=B+
136

B=936
-
13
6

=800

-
lr)+(j
-
lc)))

= 8
00+4((
(5
-
0)+
8
(1
-
0)))

=800+4(
1
3
)

=800+5
2

=852

(c) Write a function in C++ to perform Insert operation in a circular Queue containing Player’s
information (represented with the help of an array of structure PLAYER).

struct

PLAYER

{

long PID; //Player ID

char Pname[20]; //Player Name

};

Ans)

struct PLAYER

{ long PID;char Pname[20];}
P
;

const int n=5;

Int f=r=
-
1,int CQ[n];

Void cqinsert(PLAYER P)

{if(f==0&&r==n
-
1!!f==r+1)

cout<<”Overflow”;

else if(r==
-
1)

{f=r=0;

CQ[r]=P;

}

else if(r==n
-
1)

{r=0;

CQ[r]=P;}

else

{r++; CQ[r]=P;}

}

(d) Write a function
TRANSFORM(int A[4][3])
in C++ to swap the elements of the first (2)

column with the corresponding elements of last column of array A.

Ans)
void transfer(int

a[][20],int n)

{ int i,j;

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

{int temp =a[i][0];

a[i][0]=a[i][n
-
1];

a[i][n
-
1]=temp;

}

}

(e) Convert the expression (A
-
5)*6+(10/B)/2 to corresponding postfix expression. Also show the status
of operator stack after each step.

Ans) ((A
-
5)*6+
(10/B)/2

)

S.N

o

Symbol

Scanned

Stack

Expression Y

1

(

(

2

(

((

3

A

((

A

4

-

((
-

A

5

5

((
-

A
,
5

6

)

(

A
,
5
,
-

7

*

(*

A
,
5
,

-

8

6

(*

A
,
5
,

-
,
6

9

+

(+

A
,
5
,

-
,
6
,
*

10

(

(+(

A
,
5
,

-
,
6
,
*

11

10

(+(

A
,
5
,

-
,
6
,
*
,
10

12

/

(+(/

A
,
5
,

,

6
,
*
,
10

13

B

(+(/

A
,
5
,
-
,
6
,
*
,
10
,
B

14

)

(+

A
,
5
,
-
,
6
,
*
,
10
,
B
,
/

15

/

(+/

A
,
5
,
-
,
6
,
*
,
10
,
B
,
/

16

2

(+/

A
,
5
,
-
,
6
,
*
,
10
,
B
,
/
,
2

17

)

A
,
5
,
-
,
6
,
*
,
10
,
B
,
/
,
2
,
/
,
+

The corresponding postfix expression is: A,5,
-
,6,*,10,B,/,2,/,+

4.

(a) A binary file “Students.dat” contains data of 10 students where each student’s data is an
object of the following class:

class Student

{

int Rno;char Name[20];

public:

void EnterData() {cin>>Rno; cin.getline(Name,20);

void ShowData() {cout<<Rno<<

-

”<<Name<<endl;}

};

With reference to this information, write output of the following program segment:

ifstream File; Student S;

File.open(“STUDENTS.DAT”,ios::binary|ios::in);

File.seekg(0, ios::end);

Cout<<File.tellg();

Ans) 220

(b) Write a function in C++ to count the number of lines starting with a digit in a text file “DIARY.TXT”.

Ans)

void countline()

{ ifstream fn("DIARY.txt",ios::in);

char a[20];

int count=0;

while(fn)

{

fn.getline(a,20);

if(isdigit(a[0]))

count++;

}

cout<
<count;}

(c) Given a binary file “STUDENT.DAT”, containing records of the following class Student type:

class student

char S_Name[20]; //Name of student

int Percentage; //Marks percentage of student

publi
c:

void EnterData()

}

void DisplayData()

cout<<setw(32)<<S_Name;

cout<<setw(3)<<Percentage<<endl;

}

int Ret_Per() {return Percentage;}

};

Write a function in C++ that would read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 75.

Ans)

{ student s;

ifstream fn(“STUDENT.DAT”, ios::in|ios::binary);

f(s)))

{ if(s. Ret_Per()>75)

s.display();

}

5
.

(a) Observe the following Table and answer the parts (i) and (ii) accordingly

(2
)

Table : MEMBER

Mno

Name

Qty

PurchaseDate

101

Pen

102

12
-
12
-
2011

102

Pencil

201

21
-
02
-
2012

102

Eraser

90

09
-
08
-
2009

109

Sharpner

90

31
-
08
-
2012

113

Clips

900

08
-
08
-
2011

1)

In the above table,

can we make Mno as Primary key?(Answer as[YES/NO]only).Justify your

Ans:
No

Justification: The column MNo has duplicate value (102) in row 2 and row 3.

2)

What is the degree and cardinality of the table?

Ans)
Degree
---
4

Cardinality
---
5

(b) Consider the following tables SUBJECT and TEACHER and answer the following

(4)

Table:SUBJECT

Code

Title

Marks_Theory

Marks_Prac

301

English

100

0

041

Maths

100

0

083

Computer
SC

70

30

042

Physics

70

30

043

Chemistry

70

30

Table
:TEACHER

TCode

Name

Sub_Code

1

P.Jain

301

2

R.Nagpal

301

3

Supatra

041

4

Shabnam

083

5

Rashika

042

6

Vidushi

041

7

Yash

043

1)

To display the names of all subjects for
which Practical mark are 0.

Ans) select name from SUBJECT where Marks_Prac=0;

2)

To display the total number of teachers in each subject separately

Ans) select
count(*),
sub_code
from teacher group by Sub_code;

3)

To display the names of all teachers in the asc
ending order of Sub_Code.

Ans) select name from teacher order by Sub_code;

4)

To display each subject’s details along with Total_marks in each subject from the table
SUBJECT(
Total_Marks=Marks_Theory+Marks_Practical)

Ans) select
C
ode,
T
itle, Marks_Theory,
Marks_Practical ,Marks_Theory+Marks_Practical from
SUBJECT;

c) Write SQL statement to display each teacher’s name along with his/her respective subject name
from the

table TEACHER ans SUBJECT

(2)

Ans)
Here Code in SUBJECT and Sub_code in Teacher is not same attribute. If both are same name
then query should be,

Select Name
, Title from Teacher T, Subject S where T.Sub_code=S.Sub_code;

d)Give the output of th
e following SQL queries:

(1)

(i) SELECT DISTINCT(Marks_Theory) from SUBJECT;

Ans)

Marks_Theory

100

70

(ii) SELECT TCode, Name from Teacher where Sub_Code like ‘0%’;

Ans)

Tcode

Name

3

Supatra

4

Shabnam

5

Rashika

6

Vidushi

7

Yash

(e) Identify primary keys of the tables SUBJECT and TEACHER.

(1)

Ans) The Primary key of SUBJECT is Code

The Primary key of Teacher is Sub_code

6.

a) State the dual of the absorption law
X+X.Y = X
and prove it algebraically (2)

Ans)

This law states that

X(X+Y)=X

Proof:

L.
H.S=X
(
X
+
Y
)

=X
X
+
XY

=X

+

XY

(
XX=X
,

ref.

Idempotence

law
)

=X
(1+Y)

=X.1 (1+Y=1, ref. Properties of 1)

=X = R.H.S

b)

Draw the logic diagram for the Boolean expression X.(Y’+Z) using basic logic gates (2)

Ans)

X

Y
’+
Z

X.(Y’+Z)

Y

Z

c)

Write the SOP form of the Boolean function F(P,Q,R) = Σ(0,2,3,5).

Ans)

F(P,Q, R)=∑(0,2,3,5)

=m
0
+m
2
+m
3
+m
5

=P

Q

R

+PQ

R+PQ

R

+P

QR

(d) Find the simplified expression for the following Boolean function using Karnaugh’s map: F(A, B,
C, D) = Σ(0,1,2,4,5,6,8,9,10 )

Ans)

CD C

D

C

D CD CD

AB

A

B

A

B

AB

AB

0

1

1

1

3

2

1

4

1

5

1

7

6

1

12

13

15

14

8

1

9

1

11

1
0

1

F(A, B, C, D)=(A

C

)+ (A

D

)+ (B

D

)+( B

C

)

7.

(a) To provide telemedicine facility in a hilly state, a computer network is to be setup to
connect hospitals in 6 small villages (V1, V2, . . . , V6) to the base hospital (H) in the state
capital. This is shown in the following diagram.

No village is more than 20km away from the state capital.

Imagine yourself as a computer consultant for this project and answer the following questions with
justification:

(i)

Out of the following what kind of link should be provided to setup this network: (i) Microwave

Ans: i)

-
directional and can penetrate through obstacles.

(ii) What kind of network will be formed: LAN, MAN, or WAN?

(1)

Ans)
MAN

Justification: As the network will be spread over the state crossing the limits of a LAN and within the
boundaries of a MAN.

(iii) Many times doctors at village hospital will have to consu
lt senior doctors at the base hospital. For this
purpose, how should they contact them: using email, SMS, telephone, or video conference?

Ans) Video conference

Justification: Using video conference the doctors at both sides can demonstrate any
proc
edure, if needed
.

(b) Out of SMTP and POP3 which protocol is used to receive emails?

(1)

(
2
)

Ans) POP3

Justification

SMTP
-

It is used to send emails

POP3
-

It is used to retrieve emails

(c) What are cookies in the context of computer networks?

Ans)

file which is automatically sent f
rom a website and stored in the user’s
computer.

(1)

(d) Rajeshwari

is trying for on
-
line subscription to a magazine. For this she has filled in a form on the
magazine’s web site. When she clicks submit button she gets a message that she has left e
-
mail field
empty and she must fill it. For such checking which type of scr
ipt is generally executed

client
-
side
script or server
-
side script?

Ans:

Client
-
side script

(1)

(e) Mention any one difference between freeware and free software.

(1
)

Ans:

Source code of freeware is not available to the user whereas
source code of free software is
available to the user.