Isc Topicwise
Isc Topicwise
K-MAP
(1) Given the Boolean function F(A, B, C, D) = Σ(0, 1, 6, 7, 8, 9, 10, 14, 15). [2003,5]
Use Karnaugh’s map to reduce this function F, using the given SOP. Draw the logic gate diagram for the reduced
SOP form. You may use gates with more than two inputs. Assume that variables and their complements are
available as inputs.
(5) Given the following Boolean function F( A,B,C,D ) = Σ (1, 3, 7, 9, 11, 15). [2004,10]
(a) Use Karnaugh’s map to reduce the function F. Draw the logic gate diagram for the reduced SOP expression
using the Basic NOT, AND, OR gates. You may use gates with more than two inputs. Assume that variables and
their complements are available as inputs.
(b) Now implement the circuit in (a) using NAND gates only. Show relevant reasoning at each step. You
may use gates with more than two inputs.
(6) Given the Boolean function F(A, B, C, D) = Σ (0, 1, 2, 4, 5, 7, 11, 13, 15 ) [2005,5]
Using Karnaugh’s map to reduce this function F, using the given SOP form. Draw logic gate diagram for the
reduced SOP form. You may use gates with more than two inputs. Assume that variables and their complements
are available as inputs.
(8) Given the Boolean function F(A, B, C, D) = Σ (1, 6, 7, 8, 9, 10, 14, 15). [2006,5]
Use Karnaugh’s map to reduce the function F, using the SOP form. Draw a logic gate diagram for the reduced SOP
form. You may use gates with more than two inputs. Assume that variables and their complements are available as
inputs.
(9) Given the Boolean function X(A, B, C, D) = 𝜋 ( 0, 2, 3, 4, 5, 11, 12, 13). [2006,5]
Use Karnaugh’s map to reduce this function X using the given POS form. Draw a logic gate diagram for the
reduced POS form. You may use gates with more than two inputs. Assume that variables and their complements
are available as inputs.
(16)Given
F(A,B,C,D)=(A+B+C+D).(A+B+C+D').(A+B+C'+D').(A+B+C'+D).(A+B'+C+D').(A+B'+C'+D').(A'+B+C+D).(A'+B+C'+D)
Reduce the above expression by using 4- variable K-Map, showing the various groups ( i.e. octals, quads and
pairs).Draw the logic gate diagram of the reduced expression using NOR gate only. [ 5,2010 ]
(18) Given F(A,B,C,D)= A'B'C'D' + A'B'C'D + AB'C'D'+ AB'C'D + A'BC'D' +A'BCD'. [ 5,2011]
Reduce the above expression by using four variable K-map. Draw the logic gate diagram of the reduced expression
using NAND gates only
(26) Given the Boolean function: P(A, B, C, D) = ABC'D' + A'BC'D' + A'BC'D + ABC’D + A'BCD + ABCD
Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and
pairs).Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements
are available as inputs.
[5,2015]
(2) The SOP expression for a combinational circuit that detects an error in the representation of a decimal digit in
BCDE is given as : F( a, b, c, d ) = Σ ( 10, 11, 12, 13, 14, 15 ).
(a) Use Karnaugh’s map to reduce this function F, using the given SOP form. Draw the logic gate diagram for the
reduced SOP form. You may use gates with more than two inputs. Assume that variables and their complements
are available as inputs.
(b) Now implement E using the NAND gates only. Show how it is equivalent to the original circuit. You may use
gates with more than two inputs. Assume that variables and their complements are available as inputs. [2004,10]
(3) The Past Pupil Association of R. K. University Computer Science Department is organizing a reunion function
at the campus. The invitation card is to be issued to a person if –
• The person is an ex-student of the Department and has passed out in 1995.
OR
• The person is not an ex-student of the same department but passed out from the university in 1995 and has made
a contribution of Rs. 1000.
The inputs are :
E : The person is ex-student of the department.
U : The person is not an ex-student of the department, but a student of the same university.
P : The person passed out in 1995.
S : The person contributes Rs. 1000. [ 1 indicates yes and 0 indicates no in all cases ]
Output :
I : Denotes the invitation car is issued. [ 1 indicates yes and 0 indicates no ]
(a) Draw the truth table for the inputs and outputs given above and write the SOP expression for I( E, U, P, S ).
(b) Reduce I( E, U, P, S ) using Karnaugh’s map. Draw the logic gate diagram for the reduced SOP expression for
I( E, U, P, S ) using AND & OR gates. You may use gates with two or more inputs. Assume that variables and
their complements are available as inputs.
[2005,10]
(4) The National College of Journalism is offering courses in three different categories of journalism, which are the
print, the web and the broadcasting media.
A student is eligible to apply if he/she satisfies any one of the following conditions:
• The student is a graduate in any discipline with an aggregate percentage of 75 or above and with a record of
literary skills.
OR
• The student is a graduate in Mass Communication with an aggregate percentage of 75 or above.
The inputs are:-
A : Graduate in any discipline.
B : Graduate in Mass Communication.
C : Aggregate percentage of 75 and above.
D : Record of Literary skills.
Output:-
R : Denotes eligible to apply. [ 1 indicates Yes and 0 indicates No in all cases ]
(a) Draw the truth table for the inputs and outputs given above and write the SOP expression for R(A, B, C, D).
(b) Reduce R(A, B, C, D) using Karnaugh’s map. Draw the logic gate diagram for the reduced SOP expression for
R(A, B, C, D) using AND & OR gates. You may use gates with more than two inputs. Assume that variables and
their complements are available as inputs.
[2006,10]
(5) The inaugural function of the newly constructed flyover has been organized by the Public Works Department.
Apart from a few special invitees, entry is permitted only if :
The person is an employee of the PWD of Class I category with more than 10 years of work experience.
OR
The person is an employee of any other government or authorized private organization either at the managerial
level or with more than 10 years of working experience.
The inputs are:-
A : The person is a Class I employee of PWD.
B : The person is an employee of any other government or authorized private organization.
C : The person has more than 10 years of working experience.
D : The person is holding a managerial post.
Output:-
X : Denotes eligible for entry. [ 1 indicates Yes and 0 indicates No in all cases ]
(a) Draw the truth table for the inputs and outputs given above and write the SOP expression for X(A, B, C, D).
(b) Reduce X(A, B, C, D) using Karnaugh’s map. Draw the logic gate diagram for the reduced SOP expression
for X(A, B, C, D) using the AND & OR gates. You may use gates with more than two inputs. Assume that
variables and their complements are available as inputs.
[2007,10]
(6) The immigration rules of a country allows the issue of work-cum-stay permits to an applicant only if the
applicant satisfies any one of the following conditions :-
•The spouse of the applicant is a permanent resident of that country, having lived there for at least 5 years.
OR
•The applicant possesses certain special skills as specified in the ‘Skill Requirement List’ of the country and is
sponsored by a permanent resident of the country.
The inputs are:-
A : The spouse or sponsor has permanent residence status.
B : The spouse has lived in the country for 5 or more years.
C : The applicant possesses the required special skills.
D : Sponsorship by a permanent resident.
Output:-
X : Denotes eligible for permit issue. [ 1 indicates Yes and 0 indicates No in all cases ] [10,2008]
(i) Draw the truth table for the inputs and outputs given above and write the SOP expression for X(A, B, C,
D).Reduce X(A, B, C, D) using Karnaugh’s map.
(ii) Draw the logic gate diagram for the reduced SOP expression for X(A, B, C, D) using AND & OR gates. You
may use gates with two or more inputs. Assume that the variables and their compliments are available as inputs.
(7) A provisional store announces a special discount on all its products as a festival offer only to those who satisfy
any one of the following conditions:
• If he/she is an employee of the store and has a service of more than ten years
OR
• If he/she is a regular customer of the store whose age is less than 65 years and is not an employee of the store
OR
• If he/she is a senior citizen but not a regular customer of the store The inputs are: [10,2009]
E : Employee of the store
R : Regular customer of the store
S : Service of the employee is more than 10 years
C : Senior citizen of 65 years or above
Output
X : Denotes eligible for discount[ 1 indicates YES and 0 indicates NO in all cases]
a) Draw the truth table for the inputs and outputs given above an write the SOP expression for X(E,R,S,C).
b) Reduce X(E,R,S,C) using Karnaugh's map. Draw the logic gate diagram for the reduced SOP expression for
X(E,R,S,C) using AND , OR gates . You may use gates with more than 2 inputs. Assume that the variables and
their complements are available as inputs.
(8) A government institution intends to award a medal to a person who qualifies any one of the following criteria:
The person should have been an Indian citizen and had lost his/her life in a war but has not completed 25 years of
service. [ 10,2010
]
OR
The person must be an Indian citizen and has served the nation for a continuous period of 25 years or more but has
not lost his/her life in a war.
OR
The person is not an Indian citizen but has taken active part in activities for the upliftment of the nation.
The inputs are
A : The person is/was an Indian citizen
B : Has a continuous service of more than 25 years
C : Lost his/her life in a war
D : Taken part in activities for upliftment of the nation
Output
X Denotes eligible for medal [ 1 indicates YES ad 0 indicates NO in all cases]
a) Draw the truth table for the inputs and outputs given above and write the POS expression for X(A,B,C,D)..
b) Reduce X(A,B,C,D) using Karnaugh's map.
(ii) Draw the logic gate diagram for the reduced POS expression for X(A,B,C,D) using AND and OR gate. You
may use gates with two or more inputs. Assume that the variable and their complements are available as inputs.
(9) A Football Association coach analyses the criteria for a win/draw of his team depending on the following
conditions.
• If the Centre and forward players perform well but Defenders do not perform well. [10,2013 ]
OR
• If Goal keeper and Defenders perform well but the Centre players do not perform well.
OR
• If all the players perform well.
The inputs are:
INPUTS
C Centre players perform well
D Defenders perform well
F Forward players perform well
G Goalkeeper performs well (In all of the above cases 1 indicates yes and 0 indicates no)
Output: X - Denotes the win/draw criteria [ 1 indicates win/draw and 0 indicates defeat in all
cases.]
a) Draw the truth table for the inputs and outputs given above and write the POS expression for X(C,D,F,G).
b) Reduce X(C,D,F,G) using Karnaugh's map. Draw the logic gat diagram for the reduced POS expression for
X(C,D,F,G) using AND and OR gate.You may use gates with two or more inputs. Assume that the variable and
their complements are available as inputs.
(10) A school intends to select students for the Inter - school athletic meet, as per the criteria given below:
• The candidate is from the Senior school and has participated in an inter school athletic meet earlier.
OR
• The candidate is not from the Senior School, but the height is between 5 ft. and 6ft. And weight is between 50 kg
and 60 kg.
OR
• The candidate is from the senior school and has height between 5ft. And 6ft., but the weight is not between 50
and 60 kg.
The inputs are : [10,2014]
INPUTS
S : Student is from the senior school
W : Weight is between 50 kg and 60 kg
H : Height is between 5 ft. And 6 ft.
A : Taken part in Inter school athletic meet earlier (In all the above cases 1 indicates Yes and
0 indicates No.)
OUTPUT : X: Denotes the selection criteria [ 1 indicates selected and 0 indicates rejected in all cases.]
a) Draw the truth table for the inputs and outputs given above and write the SOP expression for X(S,W,H,A).
b) Reduce X(S,W,H,A) using Karnaugh map. Draw the logic gate diagram for the reduced SOP expression for
X(S,W,H,A) using AND and OR gate. You may use gates with two or more inputs. Assume that the variable and
their complements are available as inputs.
(11) A person is allowed to travel in a reserved coach of the train, if he/she satisfies the criteria given below:
• The person has a valid reservation ticket and a valid ID proof. [10,2015]
OR
• The person does not have a valid reservation ticket, but holds a valid pass issued by the Railway department with
a valid ID proof.
OR
• The person is a disabled person and holds a valid pass issued by the Railway department along with a valid ID
proof.
The inputs are:
INPUTS
R The person has a valid reservation ticket.
P The person holds a valid pass issued by the Railway department.
D The person has a valid ID proof.
H The person is a disabled person. (In all the above cases. 1 indicates yes and 0 indicates no).
Output : T - Denotes allowed to travel (1 indicates yes and 0 indicates no in all the cases)
(a) Draw the truth table for the inputs and outputs given above and write the POS expression for T(R, P, D, H).
(b) Reduce T(R, P, D, H) using Karnaugh map.
Draw the logic gate diagram for the reduced POS expression for T(R, P, D, H) using only NOR gates. You may
use gates with two or more inputs. Assume that the variable and their complements are available as inputs.
(12) A passenger is allotted a window seat in an aircraft, if he/she satisfies the criteria given below:
• The passenger is below 15 years and is accompanied by an adult. [10,2016]
OR
• The passenger is a lady and is not accompanied by an adult,
OR
• The passenger is not below 15 years, but is travelling for the first time. The inputs are:
INPUTS •
A The passenger is below 15 years age.
C The passenger is accompanied by an adult.
L The passenger is a lady.
F The passenger is travelling for the first time. (In all the above cases 1 indicates yes and 0 indicates no).
Output : W - Denotes the passenger is allotted a window seat (1 indicates yes and 0 indicates no)
Draw the truth table for the inputs and outputs given above and write the SOP expression for W(A,C,L,F).
(13) A school intends to select candidates for an Inter-School Essay Competition as per the criteria given below:
• The student has participated in an earlier competition and is very creative. [10,2017]
OR
• The student is very creative and has excellent general awareness, but. has not participated in any competition
earlier.
OR
• The student has excellent general awareness and has won prize in an inter-house competition.
The inputs are:
INPUTS ,
A : participated in a competition earlier
B : is very creative
C : won prize in an inter-house competition
D : has excellent general awareness (In all the above cases 1 indicates yes and 0 indicates no).
Output: X : selection made [1 indicates yes,.0 indicates no for all cases]
Draw the truth table for the inputs and outputs given above and write the POS expression for X(A,B,C,D).;
Inheritance
(1) A class Employee contains employee details and another class Salary calculates the employee’s net salary. The
details of the two classes are given below: [10,2008]
Class name : Employee
Data members :
empNo : stores the employee number
empName : stores the employee name
empDesig : stores the employee’s designation
Member functions/methods
Employee( ) : default constructor
Employee( . . . ) : parameterized constructor to assign values to employeenumber,
name and designation
void display( ) : display the employee details
(2) A library issues books on a rental basis at a 2% charge on the cost price of the book per day. As per the rules of
the library, a book can be retained for 7 days without any fine. If the book is returned after 7 days, a fine will also
be charged for the excess days as per the chart given below: [10,2009]
Number of excess days Fine per day
1 to 5 2.00
6 to 10 3.00
Above 10 days 5.00
Design a class Library and another class Compute to perform the task. The details of the 2 classes are given
below:
Class name : Library
Data members
name : name of the book
author : author of the book
p : price of the book in decimals
Member functions
Library(…) : parameterized constructor to assign values to data members.
void show() : display the book details
class name : Compute
Data members
d : number of days taken in returning the book.
f : to store the fine.
Member functions
Compute(…) : parameterized constructor to assign values to data Members of
both classes.
void fine() : calculate the fine for excess days.
void display() : displays the book details along with the number of days,fine and
total amount to be paid. Total amount is calculated as: (2% of price of book * total no. of days) + fine
Specify the class Library giving details of the constructors and void show(). Using the concept of inheritance,
specify the class Compute giving details of the constructor, void fine() and the void display() function. You need
not write the main function. [10,2010]
(3) A super class Worker has been defined to store the details of a worker. Define a sub class Wages to compute
the monthly wages for the worker. The details of both the classes are given below:
Class name : Worker
Data members :
Name : to store the name of the worker [ 10,2011]
Basic : to store the basic pay in decimal
Member functions
Worker(….) : parameterized constructor to assign values to the instance variables
void display() : display worker details
class name : Wages
Data members
hrs : stores the hours worked
rate : stores rate per hour
wage : stores the overall wage of the worker
Member functions
Wages(….) : parameterized constructor to assign values to the instance variables of both
classes
double overtime( ) : calculates and returns the overtime amount as (hours * rate )
void display() : calculates the wage using the formula wage=overtime amount +basic pay
and displays it along with other details
Specify the class Worker giving details of the constructor() and void display(). Using the concept of inheritance,
specify the class Wages giving details of the constructor(), double overtime() and void display(). The main
function need not be written.
(4) A super class Record has been defined to store the names and ranks of 50 students. Define a sub class Rank to
find the highest rank along with the name. The details of both classes are given below: [ 10,2012]
Class name Record
Data Mambers:
name[] : to store the names of students
rnk[] : to store the ranks of students
Member functions:
Record() : default constructor
void readvalues() : to store name and ranks
void display() : displays the names and the corresponding ranks
Specify the class Record giving details of the constructor(), void readvalues(), void display(). Using the concept of
inheritance, specify the class Rank giving details of constructor(), void highest() and void display(). The main
function and algorithm need not be written.
(5) A super class Detail has been defined to store the details of a customer. Define a sub class Bill to compute the
monthly telephone charge of the customer as per the chart given below: [ 10,2013]
NUMBER OF CALLS RATE
1- 100 Only rental charge
101-200 60 paisa per call + rental charge
201-300 80 paisa per call + rental charge
Above 300 1 rupee per call + rental charge
The details of both the classes are given below:
Class Name : Detail
Data members
name : to store the name of the customer.
address : to store the address of the customer.
telno : to store the phone number of the customer.
rent : to store the monthly rental charge
Member functions:
Detail(..) : parameterized constructor to assign values to data members.
void show() : to display the detail of the customer.
Class Name : Bill
Data members
n : to store the number of calls.
amt : to store the amount to be paid by the customer.
Member functions:
Bill(..) : parameterized constructor to assign values to data Members of both
classes and to initialize amt = 0.0.
void cal() : calculates the monthly telephone charge as per the charge given above.
void show() : to display the detail of the customer and amount to be paid.
Specify the class Detail giving details of the constructor( ) and void show(). Uisng the concept of inheritance,
specify the class Bill giving details of the constructor( ), void cal() and void show(). THE MAIN FUNCTION
AND ALGORITHM NEED NOT BE WRITTEN.
(6) A super class Perimeter has been defined to calculate the perimeter of a parallelogram. Define a sub class
Area to compute the area of the parallelogram by using the required data members of the super class. The details
are given below: [ 10,2014]
Class name : Perimeter
Data Members
a : to store the length in decimal
b : to store the breadth in decimal
Member functions:
Perimeter(…) : parameterized constructor to assign values to data Members
double Calculate() : calculate and return the perimeter of a parallelogram as 2 *(length +breadth)
void show() : to display the data members along with the perimeter of the parallelogram.
Class name : Area
Data Members
h : to store the height in decimal
b : to store the area of the parallologram
Member functions:
Area(…) : parameterized constructor to assign values to data Members of both classes.
void doarea() : computes the area( breadth * height).7
void show() : to display the data members of both the classes along with the area and perimeter
of the parallelogram.
Specify the class Perimeter giving details of the constructor(…), double Calculate() and void show().
Using the concept of inheritance, specify the class Area giving details of he constructor(…), void
doarea() and void show(). The main function and algorithm need not be written.
(7) A super class Stock has been defined to store the details of the stock of a retail store. Define a subclass
Purchase to store the details of the items purchased with the new rate and updates the stock. Some of the members
of the classes are given below: [ 10,2015]
Class name : Stock
Data members:
item : to store the name of the item
qty : to store the quantity of an item in stock
rate : store the unit price of an item
amt : to store the net value of the item in stock
Member functions:
Stock() : parameterized constructor to assign values to the data members
void display( ) : to display the stock details
Class name : Purchase
Data members
pqty : to store the purchased quantity
prate : to store the unit price of the purchased item
Member functions
Purchase(.....) : parameterized constructor to assign values to the data members of
both classes
void update() : to update stock by adding the previous quantity by the purchased quantity
and replace the rate of item if there is a difference in the purchase rate of the item if there is a difference in the
purchase rate. Also update the current stock value as: (quantity * unit price)
void display() : to display the stock details before and updation.
Specify the class Stock, giving details of the constructor() and void display().Using concept of inheritance, specify
the class Purchase, giving details of the constructor(), void update() and void display().The main function and
algorithm need not be written.
(8) A line on a plane can be represented by coordinates of the two-end points pi and p2 as pl(xl, yl) and p2(x2, y2).
A super class Plane is defined to represent a line and a sub class Circle to find the length of the radius and the area
of circle by using the required data members of super class. [ 10,2016]
Some of the members of both the classes are given below:
Class name : Plane
Data members/instance variables:
xl : to store the x-coordinate of the first end point
yl : to store the y-coordinate of the first end point
Member functions/methods:
Plane(…) : parameterized constructor to assign the data members xl=nx and yl=ny
void show( ) : to display the coordinates
Class name : Circle
Data members/instance variables:
x2 : to store the x-coordinate of the second end point
y2 : to store the y-coordinate of the second end point
radius : double variable to store the radius of the circle
area : double variable to store the area of the circle
Member functions/methods:
Circle(…) : parameterized constructor to assign values to data members of both the
classes
void findRadius( ) : to calculate the length of radius using the formula:
(9) A super class Bank has been defined to store the details of a customer. Define a sub-class Account that enables
transactions for the customer with the bank. The details of both the classes are given below:
[5,2017]
Class name : Bank
Data member/instance variable :
name : stores the name of the customer
accno : stores the account number .
p : stores the principal amount in decimals
Member functions/methods :
Bank(⋯) : parameterized constructor to assign values to the instance variables
void display( ) : displays the details of the customer
Class name Account
Data member/instance variable :
amt : stores the transaction amount in decimals
Account(⋯) : parameterized constructor to assign values to the instance variables
of both the classes
void deposit( ) : accepts the amount and updates the principal as p=p + amt
void withdraw( ) : accepts the amount and updates the principal as p=p-amt
If the withdrawal amount is more than the principal amount, then display the message “INSUFFICIENT
BALANCE”. If the principal amount after withdrawal is less than 500, then a penalty is imposed by using the
formula p=p-(500-p)/10
void display( ) : displays the details of the customer
Assume that the super class Bank has been defined. Using the concept of Inheritance, specify the class Account
giving details of the constructor, void deposit( ), void withdraw( ) and void display().The super class and the main
function need not be written.
(10) A super class Product has been defined to store the details of a product sold by a wholesaler to a retailer.
Define a sub class Sales to compute the total amount paid by the retailer with or without fine along with service
tax.Some of the members of both the classes are given below:
Class name : Product
Data member/instance variable:
name : stores the name of the product
code : integer to store the product code
amount : stores the total sale amount of the product (in decimals)
Member functions/methods :
product(String n,int c,double p) : parameterized constructor to assign data members name=n, code=c
and amount = p displays
the details of the data members
Class name : Sales
Data member/instance variable:
day : stores number of days taken to pay the sale amount
tax : to store the service tax (in decimals) to store the total amount (in decimals)
Member functions/methods :
Sales(…) : parameterized constructor to assign values to data members of both the
classes
void compute() : Calculates the service tax @ 12-4% of the actual sale amount
calculates the fine @ 2-5% of the actual sale amount only if the amount paid by the retailer to the wholesaler
exceeds 30 days calculates the total amount paid by the retailer as (actual sale amount + service tax + fine)
void show() : displays the data members of super class and the total amount
Assume that the super class Product has been defined. Using the concept of inheritance, specify the class Sales
giving the details of the constructor),void compute( ) and void show( ). The super class, main function and
algorithm need NOT be written.
OBJECT PASSING
Q1: A class Collection contains an array of 100 integers. Using the following class description create an array with
common elements from two integer arrays. Some of the members of the class are given below:
Class name : Collection
Data members/ instance variables : [10,2008]
arr[ ] : Integer array
len : length of the array
Member functions/methods
Collection( ) : default constructor
Collection( int ) : parameterized constructor to assign the length of the array.
void inparr( ) : to accept the array elements
Collection common(Collection) : returns a Collection containing the common elements of current Collection
object and the Collection object passed as a parameter
void arrange( ) : sort the array elements of the object containing common elements in ascending
order using any sorting technique
void display( ) : displays the array elements.
Specify the class Collection giving the details of the constructors, void inparr( ) and void arrange( ), Collection
common(Collection). You need not write the main function.
Q2: A transpose of an array is obtained by interchanging the elements of rows and columns. A class
Transarray contains a two dimensional integer array of order [ m x n]. The maximum value possible for
both ‘m’ and ‘n’ is 20. Design a class Transarray to find the transpose of a given matrix. The details of the
members of the class are given below: [10,2009]
Class name : Trasarray
Data members
arr[][] : stores the matrix elements
m : integer to store the number of rows.
n : integer to store the number of columns.
Member functions
Transarray() : default constructor
Transarray(int mm,int nn) : to inititalize the size of the matrix, m=mm,n=nn.
voidfillarray() : to enter elements into the matrix.
void transpose(Transarray A) : to find the transpose of a given matrix.
voiddisaparray() : displays the array in a matrix form.
Specify the class Transarray giving details of the constructors, void fillarray(), void transpose(Transarray)
and void disparray(). You need not write the main function.
Q3: The co-ordinates of a point P on a two-dimensional plane can be represented by P(x,y) with x as the x
co-ordinate and y as the y co-ordinate. The co-ordinates of midpoint of two points P1(x1,y1) and P2(x2,y2) can be
calculated as P(x,y) where: [10,2010]
x=x1+x2/2, y=y1+y2/2
Design a class Point with the following details:
Class name : Point
Data members
x : stores the x co-ordinate
y : stores the y co-ordinate
Member functions:
Point() : constructor to initialize x=0 and y=0
void readPoint() : accepts the co-ordinates x and y of a point
Point midpoint(Point A, Point B): calculates and returns the midpoint of the two points A and B.
void displaypoint() : displays the co-ordinates of a point
Specify the class Point giving details of the constructor( ), member functions void readPoint(), Point
midpoint(Point, Point) and void displaypoint() along with the main function to create an object and call
the functions accordingly to calculate the midpoint between any two given points.
Q4: A class Combine contains an array of integers which combines two arrays into a single array including the
duplicate elements, if any, and sorts the combined array. Some of the members of the class are given below:
Class Name : Combine [10,2012]
Data members
com[ ] : integer array
size : size of the array
Member functions/methods
Combine(int nn) : parameterized constructor to assign size = nn
void inputarray( ) : to accept the array elements
void sort() : sorts the elements of combined array in ascending order using the selection
sort technique.
void mix(Combine A, Combine B) : combines the parameterized object arrays and stores the result in the current
object array along with the duplicate elements , if any.
void display( ) : displays the array elements.
Specify the class Combine giving details of the constructor(int ), void inputarray( ), void sort(), void mix(Combine,
Combine) and void display( ). Also define the main function to create an object and call the methods accordingly
to enable the task.
Q5: A class Matrix contains a two dimensional integer array of order [ m x n ]. The maximum value possible for
both m and n is 25. Design a class Matrix to find the difference of the two matrices. The details of the members of
the class are given below:
Class name : Matrix [10,2013]
Data members
arr[][] : stores the matrix element
m : integer to store the number of rows
n : integer to store the number of columns
Member functions:
Matrix(int mm, int nn) : to initialize the size of the matrix m=mm and n=nn
void fillarray() : to enter the elements of the matrix
Matrix SubMat(Matrix A) : subtract the current object from the matrix of parameterized object and
return the resulting object.
void display() : display the matrix elements.
Specify the class Matrix giving details of the constructor(int,int), void fillarray(),Matrix SubMat(Matrix) and void
display(). Define the main() function to create an object and call the functions accordingly to enable the task.
Q6: A class Mixer has been defined to merge two sorted integer arrays in ascending arrays in ascending order.
Some of the members of the class are given below: [10,2014]
Q7: A class Shift contains a two dimensional integer array of order (mxn) where the maximum values of both m
and n is 5. Design the class Shift to shuffle the matrix (i.e. the first row becomes the last, the second row becomes
the first and so on). The details of the members of the class are given below: [10,2016]
Class name : Shift
Data member/instance variable:
mat[ ][ ] : Stores the array element
m : integer to store the number of rows
n : integer to store the number of columns
Member functions/methods :
Shift(int mm, int nn ) : parameterized constructor to initialize the data members m = mm and n =
nn
void input() : enters the elements of the array
void cyclic(Shift P) : enables the matrix of the object(P) to shift each row upwards in a cyclic
manner and store the resultant matrix in the current object.
void display() : displays the matrix elements
Specify the class Shift giving details of the constructor), void input(), void cyclic(Shift) and void display(). Define
the main() function to create an object and call the methods accordingly to enable the task of shifting the array
elements.
Q8: A class Adder has been defined to add any two accepted time. [10,2017]
Example: Time A - 6 hours 35 minutes
Time B - 7 hours 45 minutes
Their sum is - 14 hours 20 minutes (where 60 minutes =1 hour)
The details of the members of the class are given below:
Class name : Adder
Data member/instance variable:
a[ ] : integer array to hold two elements (hours andminutes)
Member functions/methods:
Adder( ) : constructor to assign 0 to the array elements
void readtime( ) : to enter the elements of the array
void addtime( Adder X, Adder Y) : adds the time of the two parameterized objects X and Y and stores the sum
in the current calling object
void disptime() : displays the array elements with an appropriate message (i.e. hours
= and
minutes = )
Specify the class Adder giving details of the constructor), void readtime(), void addtime(Adder, Adder) and void
disptime(). Define the main() function to create objects and call the functions accordingly to enable the task.
(Q3) The following function trial() and perform() are a part of some class. Answer the following parts
given below. Show the dry run/working.
int trial()
{
if(n==1)
return 2;
else if(n==2)
return 3;
else
return trial(n-2) + trial(n-1);
}
void perform(int p)
{
int x;
for(int i=1;i<=p;i++)
{
x=trial(i);
System.out.print(x+” “);
}
}
i) What will the function trial() return when the value of n is 4? [2]
ii) What will be the output of the function perform () when the value of p is 5? [2]
iii) In one line state what the function trial() is doing, apart from recursion? [ 1,2009]
(Q4) The following function numbers(int) and numbers1(int) are a part of some class. Answer the
questions given below showing the dry run/working:
public void numbers(int n)
{
if(n>0)
{
System.out.print(n+” “);
numbers(n-2);
System.out.print(n+” “);
}
}
public String numbers1(int n)
{
if(n<=0)
return “”;
return(numbers1(n-1)+n+” “;
}
i) What will be the output of the function numbers(int n) when n=5? [2]
ii) What will the function numbers1(int n) return when n=6? [2]
iii) State in one line what is the function numbers1(int) doing apart from recursion? [ 1,2010]
(Q5) The following is a part of some class. What will be the output of the function mymethod( ) when the
value of counter is equal to 3? Show the dry run/ working.
void mymethod(int counter)
{
if(counter= =0)
System.out.println(“ “);
else
{
System.out.println(“Hello “+ counter);
mymethod(- -counter);
System.out.println(“ “+ counter);
}
} [ 5,2011]
(Q7) The following function Recur() is a part of some class. What will be the output of the function
Recur() when the value of n is equal to 10. Show the dry run/working.
(Q9) The following function is a part of some class. Assume ‘x’ and ‘y’ are positive integers, greater than
0. Answer the given questions along with dry run / working.
void someFun(int x, int y)
{
if(x>l)
{
if(x%y=0)
{
System.out.print(y+“ ”);
someFun(x/y, y);
}
else
someFun(x, y+1);
}
}
(i) What will be returned by someFun(24,2) ?
(ii) What will be returned by someFun(84,2) ?
State in one line what does the function someFun() do, apart from recursion? [5,2015]
(Q10) The following function Check( ) is a part of some class. What will the function Check() return when
the values of both ‘m’ and V are equal to 5? Show the dry run / working. [5,2016]
int Check (int m, int n)
{
if (n = = 1)
return --m;
else
return + + m + Check (m,n);
}
(Q11) The following function magicfun( ) is a part of some class. What will the function magicfun( )
return, when the value of n=7 and n=10, respectively? Show the dry run/working: [5,2017]
int magicfun( int n)
{
if( n= = 0)
return 0;
else
return magicfun(n/2). * 10 + (p % 2);
}
Recursion (Programs)
(Q1) A class recursion has been defined to find the Fibonacci series upto a limit. Some of the members of
the class are given below:
Class name : recursion [10,2005]
Data members/ instance variables :
a, b, c, limit : integer type Member functions/methods
recursion( ) : constructor to assign a, b, c with appropriate values.
void input( ) : to accept the limit of the series
int fib(int n) : to return the nth Fibonacci term using recursive technique
void generate_fibseries( ) : to generate fibonacci series upto the given limit
(a) Specify the class recursion, giving the details of the constructor, int fib( ), void generate_fibseries( ).
You may assume other functions are written for you and you need not write the main function.
(b) Why recursive functions result into slower execution of the program?
(Q2) Class Convert has been defined to express digits of an integer in words. [10,2006]
The details of the class are given below:
Class name : Convert
Data members:
n : integer whose digits are to be expressed in words.
Member functions:
Convert( ) : constructor to assign 0 to n.
void inpnum( ) : to accept the value of n.
void extdigit(int) : to extract the digits of n using the Recursive technique.
void num_to_words(int ) : to display the digits of an integer n in words.
Specify the class Convert, giving details of the constructor and the functions, void inpnum( ), void
extdigit(int) and void num_to_words( ). The main function need not be written.
(Q3) A class Revstr defines a recursive function to reverse a string and check whether it is a 10
Palindrome. The details of the class are given below:
Class name : Revstr
Data members/Instance variables :
Str : stores the string
Revst : stores the reverse of the string
Member functions/methods :
void getStr( ) : to accept the string
void recReverse( int ) : to reverse the string using the Recursive Technique
void check( ) : to display the original string, its reverse and whether the string is a Palindrome or
not.
Specify the class Revstr giving the details of the functions void getStr( ), void recReverse(int) and void
check( ). The main function need not be written. [10,2008]
(Q4) Design a class Change to perform string related operations. The details of the class are given below:
Class name : Change
Data members
str : stores the word
newstr : stores the changed word
len : stores the length of the word Member functions
Change() : default constructor
void inputword() : to accept a word
char caseconvert(char ch) : converts the case of the character and returns it
void recchange(int): extracts characters using recursive technique and changes its case using
caseconvert() and forms a new word
void display() : displays both the words
b) Specify the class Change, giving details of the constructor(), member functions void inputword(), char
caseconvert(char ch), void recchange(int) and void display(). Define the main function to create an object
and call the functions accordingly to enable the above change in the given word. [8]
c) Differentiate between finite and infinite recursion. [ 2,2010]
(Q5) A class DeciOct has been defined to convert a decimal number into its equivalent octal number.
Some of the members of the class are given below:
Class name : DeciOct
Data members
n : stores the decimal number
oct : stores the equivalent octal number
Member functions:
DeciOct() : constructor to initialize the data members to 0
void getnum(int nn) : assigns nn to n
void deci_oct() : calculates the octal equivalent of n and stores it in oct using the recursive technique
void show() : displays the decimal number n calls the function deci_oct() and displays its octal
equivalent
a) Specify the class DeciOct, giving details of the constructor(), void getnum(int), void deci_oct() and void
show(). Also define a main function to create an object and call the functions accordingly to enable the
task.
b) State any two disadvantages of using recursion. [ 10,2011]
(Q6) A happy number is a number in which the eventual sum of the square of the digits of the number is
equal to 1. [10,2012]
Example :
28 = (2)2 + ( 8 )2 = 4 + 64 = 68
68 = (6)2 + ( 8)2 = 36 + 64 = 100
100 = ( 1 )2 + ( 0 )2 + ( 0 )2 = 1 + 0 + 0 = 1
Hence 28 is a happy number.
Example :
12 = (1)2 + (2)2 = 1 + 4 = 5 Hence 12 is not a happy number.
Design a class Happy to check if a given number is a happy number. Some of the members of the class
are given below:
Class Name : Happy
Data Members
n: stores the number
Member functions:
Happy( ) : constructor to assign 0 to n
void getnum(intnn) : to assign the parameter value to the number n = nn
int sum_sq_digits(int x) : returns the sum of the square of the digits of the number x, using the
recursive
technique.
void ishappy() : checks if the given number is a happy by calling the functionsum_sq_digits(int) and
displays an appropriate message.
Specify the class Happy giving details of the constructor( ), void getnum( int), intsum_sq_digits(int) and
void ishappy(). Also define a main function to create an object and call the methods to check for a happy
number.
(Q6) An emirp number is a number which is prime backwards and forwards. Example: 13 and 31 are both
prime numbers. Thus 13 is an emirp number.
Design a class Emirp to check if a given number is Emirp number or nt. Some of the members of the class
are given below:
Class Name : Emirp
Data Members
n : stores the number
rev : stores the reverse of the number
f : stores the divisor
Member functions
Emirp(int nn) : to assign n=nn, rev=0, and f=2
int isprime(int x) : check if the number is prime using the recursive technique and return 1 if
prime
otherwise return 0.
void isEmirp() : reverse the given number and check if both the original number and the
reverse number are prime, by invoking the function isprime(int) and display the result with an appropriate
message.
Specify the class Emirp giving details of the constructor(int), int isprime(int) and void isEmirp(). Define
the main function to create an object and call the methods to check for Emirp number. [10,2013]
(Q7) A class SeriesSum is designed to calculate the sum of the following series:-
Sum= x2/1! + x4/3!+x6/5!+….xn/(n-1)!
Some of the members of the class are given below:
Class name : SeriesSum
Data members
x : to store an integer number
n : to store number of terms
sum : double variable to store the sum of the series
Member functions
SeriesSum(intxx,intnn) : constructor to assign x=xx, n=nn
doublefindfact(int m) : to return the factorial of m using recursive technique
void calculate() : to calculate the sum of the series by invoking the recursive functions repeatedly
void display() : to display the sum of the series
a) Specify the class SeriesSum, giving details of the constructor(int,int), double findfact(int), double
findpower(int,int), void calculate() and void display(). Define the main() function to create an object and
call the functions accordingly to enable the task. [8]
b) State the two differences between iteration and recursion. [2,2014]
(Q8) A class Admission contains the admission numbers of 100 students. Some of the data [10] members /
member functions are given below:
Class name Admission
Data member/instance variable:
Adno[ ] : integer array to store admission numbers
Member functions/methods:
Admission() : constructor to initialize the array elements
void fillArray() : to accept the elements of the array in ascending order
int binSearch(int 1, int u, int v) : to search for a particular admission number (v)
using binary search and recursive technique and returns 1 if found otherwise returns -1Specify the class
Admission giving details of the constructor, void fillArray( ) and int binSearch(int, int, int). Define the
main() function to create an object and call the functions accordingly to enable the task. [10,2015]
(Q9) A disarium number is a number in which the sum of the digits to the power of their respective
position is equal to the number itself. [10,2016]
Example: 135 = i'+32 + 53 Hence, 135 is a disarium number.
Design a class Disarium to check if a given number is a disarium number or not. Some of the members of
the class are given below:
Class name : Disarium
Data member/instance variable :
int num : stores the number
int size : stores the size of the number
Member functions/methods :
Disarium(int nn) : parameterized constructor to initialize the data members n = nn and size = 0
void countDigit( ) : counts the total number of digits and assigns it to size
int sumOfDigit(int n,int p): (returns the sum of the digits of the number(n) to the power of their
respective
positions(p) using recursive technique
void check( ) : checks whether the number is a disarium number and displays the result with an
appropriate message
Specify the class Disarium giving the details of the constructor ), void countDigit( ), int sumofDigits(int,
int) and void check(). Define the main() function to create an object and call the functions accordingly to
enable the task.
(Q10)A class Palin has been defined to check whether a positive number is a Palindrome number or not.
The number ‘N’ is palindrome if the original number and its reverse are same. Some of the members of the
class are given below:
Class name : Palin [10,2017]
Data members/instance variables:
num : integer to store the number
revnum : integer to store the reverse of the number
Methods/Member functions:
Palin( ) : constructor to initialize data members with legal initial values
void accept( ) : to accept the number
int reverse(int y) : reverses the parameterized argument y and stores it in ‘revnum’
using recursive technique
void check( ) : checks whether the number is a Palindrome by invoking the function
reverse( ) and display the result with an appropriate message
Specify the class Palin giving the details of the constructor ), void accept( ), int reverse( int) and void
check( ). Define the main() function to create an object and call the functions accordingly to enable the
task.
(Q11) Design a class Perfect to check if a given number is a perfect number or not. [A number is said to be
perfect if sum of the factors of the number excluding itself is equal to the original number]
Example : 6 = 1+ 2 +3 (where 1,2 and 3 are factors of 6, excluding itself)
Some of the members of the class are given below: [10,2018]
class: Perfect
num:to store the number
Perfect(int nn) : parameterized constructor to initialize the data member num=nn
int sum_of_factors(int i) : returns the sum of the factors of the number(num), excluding itself, using
recursive technique
void chcck() : checks whether the given number is perfect by invoking the function sum_of_factors( ) and
displays the result with an appropriate message
Specify the class Perfect giving details of the constructor ), int sum_of_factors(int) and void chcck( ).
Define a main( ) function to create an object and call the functions accordingly to enable the task.