Page 1
2018 III 21 1000 Seat No. :
Time : 2½ Hours COMPUTER SCIENCE (New Pattern)
Subject Code
#
%
0
Total No. of Questions : 28 (Printed Pages : 11) Maximum Marks : 55
INSTRUCTIONS : i) All questions are compulsory, however there is an internal
choice for question number 22, 27 and 28.
ii) Question number from 1 to 5 should be attempted once.
iii) Programs should be written in C++ only.
iv) State your assumptions clearly.
Section A : Consists of 10 questions of 01 mark each.
Section B : Consists of 11 questions of 02 marks each.
Section C : Consists of 05 questions of 03 marks each.
Section D : Consists of 02 questions of 04 marks each.
SECTION A
1. Write the correct alternative from those given below :
The act of representing essential features without including the background details
or explanations is ___________. [1]
Data abstraction
Data encapsulation
Inheritance
Polymorphism
2. Write the correct alternative from those given below : [1]
Stack is also called as __________ data structure.
Last in last out
First in first out
Last in first out
First in last out
H-705 -1- P.T.O.
Page 2
3. Write the correct alternative from those given below : [1]
Which stream class is used to perform reading and writing on files ?
ofstream
fstream
ifstream
iostream
4. Write the correct alternative from those given below : [1]
On application of the de-Morgons law to the expression ) * +
we get ______
) * +
) * +
) * +
A+B+C
5. Write the correct alternative from those given below : [1]
A school plans to connect its department buildings within its campus.
Which communication channel is best suited for high speed connectivity ?
Optical fibre cable
Co-axial cable
Twisted pair cable
USB cable
6. Define multiple inheritance. [1]
7. State the pre-requisite condition for binary search to perform. [1]
8. The initial configuration of a queue is A, B, C, D (A is at the front end). To get the
configuration (D, C, B, A). How many addition and deletion operations do
we need ? [1]
9. Define FTP protocol. [1]
10. Define repeater. [1]
H-705 -2-
Page 3
SECTION B
11. Determine the output of the following C++ code. [2]
# include <iostream.h>
int main ()
{
int a = 10, count = 0;
while (++a<15)
{
cout <<a<<\t;
count ++;
a++;
}
cout <<a<<\t<<count;
}
12. List any two features of object oriented programming. [2]
13. Determine the output of the following C++ program. [2]
# include <iostream.h>
class person
{
int roll no;
int age;
public :
person (int p = 2)
{
roll no = p;
age = 20;
}
person (person &x)
{
roll no = x.roll no;
age = x.age;
H-705 -3- P.T.O.
Page 4
}
void view ()
{
cout<< roll no << : <<age<<endl;
}
};
int main ()
{
person a, b (5), c(b);
a.view ()
c.view ();
}
14. Write a user defined function pattern () which accepts a positive integer n as
parameter and generates the following pattern for n lines. [2]
if n = 4
!
" !
15. State two points of difference between linked list and arrays. [2]
16. Consider the following program. [2]
# include <fstream.h>
#include<iostream.h>
class worker
{
int wno;
char wname [20];
public :
________
________
};
H-705 -4-
Page 5
int main ()
{
worker 2;
fstream file;
file.open (worker.dat, ios : : binary/ios : : in);
________________// statement 1.
int bytes = ____________ // statement 2.
int count = bytes/sizeof (2).
cout <<the number of records are <<count;
}
Complete statement 1 and statement 2 to determine the total number of records
present in file worker.dat.
17. Consider a text file named numbers.txt consisting of positive natural numbers
into it. Write a program that reads numbers.txt and write all even numbers to the
text file even numbers.txt. (Assume that the file contains one integer number
on each line). [2]
18. Draw the truth table for half adder. Write the expression for sum and carry of half
adder. [2]
19. Given the truth table of a function F(X, Y, Z). Write the S.O.P. form and P.O.S.
form (canonical) from the following truth table. [2]
X Y Z F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
20. Write a short note on circuit switching technique. [2]
21. State two points of difference between bus topology and star topology. [2]
H-705 -5- P.T.O.
Page 6
SECTION C
22. Consider the following program. [3]
# include <iostream.h>
int check_amicable (int);
int main ()
{
int first, second;
cout <<Enter the first number<<endl;
cin>> first;
cout <<Enter the second number <<endl;
cin>> second;
___________//MISSING
___________//CODE
___________
}
Write a user defined function
Check_amicable which accepts a positive integer number and returns the sum
of the factors of the numbers excluding the number itself.
Further write only the missing code to check if the numbers entered are amicable
numbers or not.
(Amicable numbers are two positive numbers so related that the sum of the
factors of the first number excluding the number itself is equal to the second
number and the sum of factors of the second number excluding the number itself
is equal to the first number.)
Eg : 220 and 284 are amicable numbers.
The factors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110 which equals 284.
The factors of 284 are 1, 2, 4, 71 and 142 which equals 220.
OR
H-705 -6-
Page 7
Consider the following program.
# include <iostream.h>
int check_emirp(int);
int main ()
{
int reverse (int);// the function determines the reversal of the argument
int num;r;
cout <<enter a number;
cin>> num; r=reverse (num);
__________ MISSING
__________ CODE
__________
}
Write a user defined function
check_emirp which accepts a positive integer number and returns 1 if the number
is prime and 0 if the number is composite.
Further write only the missing code to determine whether the number entered is
an emirp number or not.
(An emirp number is a prime number whose reversal is also a prime number)
Eg : 13 is an emirp number.
13 is a prime number
31 is also a prime number.
23. Define a class named convert with the following specifications. [3]
feet of type integer
inch of type integer
define a default constructor which accepts values for all the data members.
define a copy constructor which accepts two objects as parameters and
initialises data members as per the summation of quantities of both the objects.
(Refer example below)
define member function view () to display values of data members of all the
objects.
H-705 -7- P.T.O.
Page 8
Further write appropriate main function.
Example : if obj 1 is 3 ft 4 inches
obj 2 is 5 ft 9 inches
obj 3 is 9 ft 1 inches.
24. Explain the concept of converting infix expression to postfix expression in a
tabular form with the following expression. [3]
(A + (B (C D))/E)
25. Given a binary file club.dat containing records of the following type. [3]
Class club
{
int mno;
char mname [20];
char member_type [15];
public :
void register ();
void display ();
int check (char s[ ] )
{
return strcmp (member_type,s);
}
};
Write a function split () in C++ that would copy all those records which are
having member_type as Life to binary file lifemembers.dat else copy the records
to temporary.dat.
26. Obtain a simplified S.O.P. form for the Boolean expression using K-map. [3]
f(U, V, W, Z) = (0, 1, 3, 4, 5, 7, 9, 10, 11, 13, 15)
Also draw the logic circuit diagram for the simplified expression using basic
gates.
H-705 -8-
Page 9
SECTION D
27. Declare an abstract class named employee with the following members. [4]
1) empid-of type integer under private visibility label.
2) constructor to only initialise data member empid.
3) display () a function under protected visibility label to display the data
member empid.
Declare an abstract class named income with the following members.
1) salary of type float under private visibility label.
2) constructor to only initialise data member salary.
3) display () a function under protected visibility label to display the data
member salary.
Declare a class named office with the following members.
1) name a character array of size 30 under private visibility label.
2) x of type employee under private visibility label.
3) y of type income under private visibility label.
4) constructor to only initialise data member name.
5) display () a function under public visibility label to display the data member
name.
Write a main function to accept the input values and display the data members of
all the classes.
OR
Declare an abstract class named regularedu with the following members.
1) schoolcode of type integer under private visibility label.
2) parameterized constructor to only initialise data member schoolcode.
3) display () a function under protected visibility label to display the data
member schoolcode.
H-705 -9- P.T.O.
Page 10
Declare an abstract class named distanceedu with the following members :
1) Study centerid of type integer under private visibility label.
2) Parameterized constructor to only initialise data member study centerid.
3) Display () a function under protected visibility label to display the data
member studycenterid.
Derive a class course from class regularedu and distanceedu both in public
mode.
The class has the following members.
1) Course code of type integer under private visibility label.
2) A parameterized constructor to only initialise the data members.
3) Display () a function under public visibility to display the data members.
Write a main function to accept input values and display data members of all the
classes.
28. Consider the following class declaration. [4]
Class list
{
struct node
{
int data;
node next;
} first;
public :
list ()
{
first = NULL;
}
void create ();
void view ();
};
Write the function definitions for the following.
1) create () to create a list of n nodes.
2) view () to display only those nodes whose data is greater than 100.
OR
H-705 -10-
Page 11
Consider the following class declaration. [4]
Class list
{
struct node
{
int data;
node
next;
}
first;
public :
list ()
{
first = NULL;
}
void del ();
void search ();
};
Write the function definitions for the following.
1) del () to delete a node present at position pos from the linked list containing
n nodes.
2) search () to search for a particular element in the linked list.
______________
H-705 -11- P.T.O.