Set 3
Set 3
Set 3
SET- 3
PART- 1
(THEORY)
Question 1
c) Draw the truth table and logic circuit for a 2-input XNOR gate. [2]
d) Find the complement of the following expression: [2]
X' +XY'
e) If (X Y ) then write its: [2]
(i) Converse
(ii) Contra positive
Question 2
Question 3
a) The following function is a part of some class which computes and sorts
an array arr[ ] in ascending order using the bubble sort technique. There
are some places in the code marked by ?l '!, ?2?, ?3?, ?4?, ?S? which
must be replaced by a statement / expression so that the function works
properly:
Void bubblesort( i nt arr[ ])
{
int i, .j, k, tmp:
for(i= 0: ?l?; i++)
{
for(j = 0; ?2?; j++)
{
if(aJT[j] > ?3?)
{
tmp = arr[j]:
?4? = arr[j+ 1];
arr[j+1] = ?5?
}
}
}
}
(i) What is the expression or statement at ?1 ? [1]
(ii) What is the expression or statement at ?2? [1]
(iii) What is the expression or statement at ?3? [1]
(iv) What is the expression or statement at ?4? [1]
(v) What is the expression or statement at ?5? [1]
b) The following function witty( ) is a part of some class. What will be the
output of the function witty() when the value of n is "SCIENCE" and the
value or p is 5. Show the dry run I working:
void witty(String n, int p)
{
If (p<0)
System.ollt.printlnC");
else
{ System.out.println(n.charAt(p) + , .. " );
witty(n, p-l);
System.out.print(n.charAt(p ));
}
}
Question 6
a) Verify algebraically if,
X'Y'Z' + X'Y'Z + X'YZ + X'YZ' + XY'Z' + XY'Z = X'+Y' [2]
b) Represent the Boolean expression X+YZ' with the help of NOR gates [2]
only.
c) Define the terms Contingency, Contradiction and Tautology. [3]
d) Consider the following truth table where A and B are two inputs and X is
the output:
A B X
0 0 0
0 1 1
1 0 1
1 1 1
(i) Name and draw the logic gate for the given truth table. [2]
(ii) Write the POS of X(A,B). [1]
Question 7
a) Define Multiplexer and state one of its uses. Draw the logic
diagram for a 4: 1 Multiplexer. [4]
b) State how a Half Adder is different from a Full Adder. Also give
their respective uses. [3]
c) Minimize the following expression using Boolean laws:
Q . ( Q' + P) . R .( Q + R )
Also draw the logic gate for the reduced expression.
Question 8
A class Combine contains an array of integers which combines two arrays into
a single [101 array including the duplicate elements, if any, and sorts the
combined array. Some of the members of the class are given below:
Member functions/methods:
technique.
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.
Question 9
Design a class Vowel Word to accept a sentence and calculate the frequency of
words that (101 begin with a vowel. The words in the input string are
separated by a single blank space and tenninated by a full stop. The description
of the class is given below:
Member functions:
vowel.
Specify the class VowelWord giving details of the constructor(), void readstr(),
void freq_ vowel( ) and void display( ). Also define the main( ) function to
create an object and call the methods accordingly to enable the task.
Question10
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]
68=(6)2+(8)2=36+64=100
100=(1)2+(0)2+(0)2=1+0+0=1
Example: 12 =(1)2+(2)2=1+4=5
Member functions:
recursive technique
appropriate message
Specify the class Happy gIvmg details of the constructor( ), void getnum(int),
int sum_sq_digits(int) and void ishappy( ). Also define a main( ) function to
create an object and call the methods to check for happy number.
Question 12
A super class Detail has been defined to store the details of a customer. Define
a ItO] sub class Bill to compute the monthly telephone charge of the customer
as per the chart given below: [10]
:customer
Member functions:
customer.
Member functions:
Specify the class Detail giving details of the constructor( ) and void show( ).
Using the concept of inheritance, specify the class Bill giving details of the
constructor( ), void cal( ) and void show( ).