Vous êtes sur la page 1sur 9

FTCOMSET2AK1215

First Term Examination 2015-16

Subject: Computer Science


Grade: XII

4/6/15

Max. Marks: 70
Time: 3 hrs

General Instructions:Please check that this question paper contains 6 printed pages.
Please write down the serial number of the question before attempting it.
Programming Language : C++
1 a)
Find the correct identifiers from the following which can be used for naming 2
variable, functions etc.
int_num, Marks Maths, Break, count, 12Grade, Amt_in_$, Sqrt, random
int_num, Break, count, Sqrt
mark for each
b)
Name the header files required to execute the following code:
1
void main()
{
int ctr= 0 , num1;
char string[] = 2015 Batch Comp. Sc. DPS;
for ( int k = 0 ; string[k]!=\0; k++)
if(isupper(string[k])
ctr++;
cout<<(string);
}
ctype.h iostream.h mark for each
c)
Rewrite the following code after removing syntax errors
2
#include <iostream.h>
const int Num = 3;
void main ()
{
int Value=15;
for (int K = 1; K<=5; K++,Value -= 2)
if (Value % Num==0)
{ cout<<Value * Num;
cout<<endl; }
Page 1 of 9

d)

e)

f)

a)

b)

else
cout<<Value + Num<<endl;
} // for each error
Find the output of the following program code:
Note: Assume all required header files are included.
a is 28 b is 12
a is 48 b is 12
a is 48 b is 70
mark for each correct value printed.
Go through the C++ code shown below, and find out the possible output(s)
from the suggested output options (i) to(iv).
iii) 11:12:13:14:15:#
iv) 14:15:#
1 mark each for correct answer
Write a function power() that takes two arguments, a double for n and an
integer value for p and returns the result as double. The function takes a
default value of p as 3, so that a cube is calculated if this argument in
omitted. Use of the inbuilt function pow() is NOT ALLOWED.
double power(double n, int p) // mark
{
double val= 1;
for( int k = 0 ; k<p ; k++) // mark
val = val * n; // mark
return val; // mark
}
What do you understand by function overloading in context with Object
oriented Programming. Explain giving suitable examples (codes).
A function having same name but several definitions which are
differentiable by the signature i.e. number or type of their arguments
is known as function overloading.
Example:
void disp() { cout<<\n Hello; }
void disp(int n) { for ( int i = 0 ; i<n ; i++) cout<< \n<< i; }
void disp( int n, int m) { for( int i = n; i<=m ; i++) cout<< \n<< n*m; }
void disp( int n, char a[]) { for ( int k = 0 ; k<n ;k ++) { cout<< \n<< a;}
1 mark for correct explanation of function overloading
1 mark for valid example
Define a class student with the given specifications
class student
Page 2 of 9

a)

b)

c)
i)

long admno;
char name[20], course[30];
float fee;
public:
student()
{ admno = 0; strcpy(name, Not Initialized;
strcpy( course, Not Initialized; fee = -100.00; }
student( long a, char na[], char co[])
{ admno = a; strcpy(name, na); strcpy(course, co);
if strcmpi(course, Oracle)==0) fee = 4590;
else if (strcmpi(course, Java)==0) fee = 6570;
else if ( strcmpi(course, Graphic Designing) ==0) fee = 9000;
}
student(student & s)
{ admno = s.admno +1; strcpy(name, s.name);
strcpy(couse, s.course); fee = s.fee; }
void print() { cout<< \n<< admno; cout<<\n<< name;
cout<< \n<<course<< \n<<fee; }
~student() { cout<< \n Work done; }

};
// 1 mark for default constructor
// 1 mark for parameterized constructor
// 1 mark for copy constructor
// mark for print and for destructor
Abstract class: The class that serves only as a base class form which other 1
classes are derived but no object of this base class type exists.
Concrete class : The class that acts as a base class but objects of this class
do exist.
// 1 mark for each definition
Define a class Worker having the following specifications
4
// mark for correct sytax of class header
// 1 mark for correct definition of function assign_wage
// 1 mark for correct definition of calc_wage
// mark for accept and correct invocation of assign_wage
// 1 mark for Print and correct invocation of calc_wage
Using the given class Member, write functions for the following:
To display the records of members paying charges between 10000 and 2
15500.
Page 3 of 9

ii)

void Disp( Member M[] , int n ) // mark


{
for ( int k = 0 k< n ; k++) // mark
if(M[k].ret_charges()<=10000 && m[k].ret_charges()<=15500)
//mark
M[k].dispemp(); // mark
}
To count the number of members paying more than 30000 and are in the 3
category Annual.
void Count(Member M[], int n) // mark
{
Int ctr= 0 ; // mark
for ( int k = 0 ; k<n ;k++) // mark
{
if( M[k]. check_cat(Annual)==0) // Mark
if( M[k].ret_charges()>30000)// mark
ctr ++ ; // mark
}

a)

}
Answer questions i) to iv) based on the following:
Hierarchical // 1 Mark
Perimeter, fencing cost, calc(), display(), length, breadth, Accept
and Print // 1 mark
iii)
None // 1 mark
iv)
Rectangle , Perimeter // 1 Mark
v)
36 // 1 Mark
What is the difference between members in private visibility mode and the
members in protected visibility mode? Give a suitable C++ code to illustrate
both.
1 mark for difference and 1 for example.
Explain the difference between get() and getline() functions.
get() is used to read characters whereas getline is used to read strings.
Get takes only 1 parameter whereas getline takes 3/2 parameters.
mark for explaining each.
Assuming a text file Textbook.txt contains strings of data. Write functions
for:
i)
void Read()
i)
ii)

b)

a)

b)

Page 4 of 9

1
1
1
1
1
2

ii)

iii)

ifstream f1(Textbook.txt); // mark


char words[20]; // mark
if(!f1)
cout<<File could not be opened;
while(f1>>words) // mark
cout<<words<<endl; // mark
f1.close();

}
3
int Count()
{
ifstream f1(Textbook.txt); // mark
int count= 0; char words[20]; // mark
if(!f1)
cout<<File could not be opened;
while(f1>>words) // mark
{
if(strcmpi(Words,Database)==0||
strcmpi(Words,Boolean)==0) // mark
count++; // mark
f1.close();
return count;// mark
}
//Deduct mark if function header does not reflect int return
type
void Print()
{
ifstream f1(Textbook.txt); // mark
char words[20]; // mark
if(!f1)
cout<<File could not be opened;
while(f1>>words) // mark
{
for(int k = 0 ; words[k]!=\0; k++)// mark
{
switch(toupper(words[k])) // 1 mark
{
Page 5 of 9

case A :
case E :
case I :
case O :
case U : break;
default : cout<<words<<\n;

}
f1.close();

iv)

v)

}
void CountAD()
{
ifstream f1(Textbook.txt); // mark
int count1= 0, count2=0; char words; // mark
if(!f1)
cout<<File could not be opened;
while(f1>>words) // mark
{
if(isalpha(words))
count1++; // mark
else if ( isdigit(words))
count2++; // mark
f1.close();
cout<<\n not of alphabets are<< count1;
cout<<\n Non of digits are << count2;
// mark for printing both
}
void Copy()
{
ifstream f1(Textbook.txt); ofstream f2(Mfile.txt);
// mark each for opening both correctly
char Lines[90]; // mark
if(!f1)
cout<<File could not be opened;
while(f1.getline(Lines, 90, #)) // mark
{
If(Lines[0]==M ||Lines[0] ==m)// mark
Page 6 of 9

f2<<words<<endl; // mark
f1.close();
f2.close();

a)

b)

c)

d)

e)

a)

}
State De Morgans theorem and prove any one algebraically.
De Morgan states that
(X.Y) = X + Y
(X+Y) = X. Y
1 mark for stating both theorems and 1 for proof of any one
Find the complement and dual of the given expression
( XY +Z W )
Complement (X +Y) ( Z + W)
Dual ( X + Y) ( Z + W)
mark for each correct expression
Convert [( X Y ) +( X Z)] into Canonical SOP form.
= XYZ + XYZ + XYZ + XYZ +XYZ
//2 MARK FOR THE CORRECT SOP
Draw a logic circuit using NAND gates only.
( X + Y ) ( XY +XY)
= X Y + XY
= (XY + XY)
= ((XY). (XY))
// 1 mark for expression and 1 for logic circuit
Reduce the given expression using K- Map
F(P, Q, R, S) = ( 0, 2, 3, 4, 6, 7, 9, 11, 12, 13)

(P+S) ( P+R) (P + Q +R) ( P+ Q + S)


// 1 mark for plotting the k-map
// 1 mark for correct groupings
// 1 mark for correct POS
Differentiate between packet switching and message switching technique in 2
network communication.
Packet switching: In packet switching, a fixed size of data packet that
can be transmitted across the network is specified and then the data
packets are sent through switching stations to the final destination.
All the packets are stored in the main memory instead of disk. As a
result accessing time of packets is reduced.
Message switching: The source computer sends data (message) to the
switching station, which stores data in a buffer. It then looks for a free
Page 7 of 9

b)

link to another switching station and sends data to that station. This
process continues until data is delivered to the destination computer.
This type of switching technique is also known as "store and forward"
switching.
( Marks for written OR diagrammatic explanation of correct Packet
Switching)
( Marks for written OR diagrammatic explanation of correct Message
Switching)
Differentiate between the following
2
i)
BUS and STAR topology of networks.
Bus Topology
Star Topology
Slower as compared to star
Expensive as compared to Bus
Breakage of wire at any point Long wire length
disturbs the entire network
(1/2 Marks for written or diagrammatic explanation of correct Bus Topology)
(1/2 Marks for written or diagrammatic explanation of correct Star Topology)
ii)

c)

d)

Compare coaxial and optical fiber cable.


Coaxial cable consists of a solid wire core surrounded by one or
more foil or wire shield, each separated by some kind of plastic
insulator. Optical fibers consists of thin strands of glass or glass
like material which are so constructed that they carry light from
a source at one end of the fiber to a detector at the other end.
mark for explaining each correctly.
Explain function of hub and router.
2
Hub: A hub contains multiple ports. When a packet arrives at one port,
it is copied to all the ports of the hub. When the packets are copied,
the destination address in the frame does not change to a broadcast
address. It does this in a rudimentary way, it simply copies the data to
all of the Nodes connected to the hub.
2. Router : routers are networking devices that forward data packets
between networks using headers and forwarding tables to determine
the best path to forward the packets
// 1 mark for correct explanation of hub and 1 for router
ABC Corporation has set up its new centre at Mumbai for its office and web
based activities. It has four building as shown in the diagram below
i)
Suggest the most appropriate location of the server to get the best 1
Page 8 of 9

ii)

iii)

iv)

connectivity for maximum number of computers. Justify your answer.


Block A as it holds maximum number of computers.
// for block and for justification.
Suggest and draw the cable layout to efficiently connect various 1
buildings for connecting the computers.
B- C- A D Bus topology
// mark for drawing the layout and for bus topology
Suggest the placement of the following devices with justification
1
(a) Repeater Between blocks C & A and A and D as distance is
more than 90 m
(b) Hub/Switch in each block to connect the computers in that
block.
// mark for each
The company is planning to link its front office situated in the city in 1
a hilly region where cable connection is not feasible, suggest an
economic way to connect it with reasonably high speed?
The most economical way to connect it with a reasonable high
speed would be to use radio wave transmission, as they are easy
to install, can travel long distances, and penetrate buildings
easily, so they are widely used for communication, both indoors
and outdoors. Radio waves also have the advantage of being
Omni directional, which is they can travel in all the directions
from the source, so that the transmitter and receiver do not
have to be carefully aligned physically.
// 1 mark for correct answer

Page 9 of 9

Vous aimerez peut-être aussi