question on classes
TRANSCRIPT
-
8/11/2019 Question on Classes
1/25
-
8/11/2019 Question on Classes
2/25
-
8/11/2019 Question on Classes
3/25
-
8/11/2019 Question on Classes
4/25
Member Functions
(i) To assign initial values
(ii) To issue a book after checking for its availability
(iii) To return a book
(iv)To display book information.
Q. Declare a class to represent fixed-deposit account of 10 customers with the following
data members:
Name of the depositor, Account Number, Time Period (1 or 3 or 5 years), Amount.
The class also contains following member functions:
(a) To initialize data members.
(b) For withdrawal of money (after the time period has passed).
(c) To display the data members.
Q. Define a class to represent batsmen in a cricket team. Include the following members:
Data Members:
First name, Last name, Runs made, Number of fours, Number of sixesMember Functions:
(i) To assign the initial values
(ii) To update runs made .
(iii) To display the batsmans information
Make appropriate assumptions wherever required.
Q. Consider the following class declaration and answer the questions below:
class SmallObj
{
private:
int some,more;
void err_1() {cout
-
8/11/2019 Question on Classes
5/25
CONSTRUCTOR AND DESTRUCTOR QUESTIONS
Very short answer questions
Q. Define constructor.
Constructor is a special member function used to initialize the membervariables of an
object.
Q. What should be the name of the object?
The name of a constructor is the same as the name of the class.
Q. In which section constructors should be declared?
The constructors should be declared in the public section.
Q. Why constructor is required?
The purpose of a constructor is to mainly initialize the member variables of a class.
Q. What is meant by default constructor?
A default constructor is a special member function which is invoked by the C++ compilerwithout any argument for initialising the objects of a class.
-
8/11/2019 Question on Classes
6/25
Q. Define a parameterised constructor.
The constructor that can take arguments are called parameterized constructor.
Q. What is the significance of parameterised constructor?
This helps you to assign initial value to an object at the time of its creation.
Q. Can we have more than one default constructor?
We can have only one default constructor in the class declaration.
Q. When default constructor is considered equivalent to a parameterized constructor?
Parameterized constructor with default argument is equivalent to a default constructor.
Q. Give the syntax of parameterised constructor.
Class_Name Object_Name(argument1, argument2, ...);
Q. How object copying is done?
It is through copy constructor.
Q. What to do you mean by dynamic intialiasation of constructor?
The initial value of an object can be provided during run time.
Q. What is a destructor?
A destructor is another special kind of class member function that is executed when an
object of that class is destroyed.
Q. Can a destructor takes arguments?
No.
Q. What is the advantage of declaring the constructor and destructor functions for public
member access?
The advantage is that constructor and destructor can be called directly by code in main()
functions.
Short answer questions
Q. Give the usage of constructor
It is used to initialise the values of the object. It doesnt return any value.
Q. Give the syntax of defining a constructor.
class ClassName
{ {
Private:................
public :
-
8/11/2019 Question on Classes
7/25
ClassName ( ) {
............... }
Q. Mention the different types of constructors.
Constructors are normally classified as follows:
1. Default Constructors
2. Parameterized Constructors
3. Constructor overloading
4. Constructor with default arguments
5. Copy Constructors
Q. Give the syntax of parameterised constructor.
Class_Name Object_Name(argument1, argument2, ...);
Q. What are the situations a copy constructor is used?
The situations are:
The initialization of an object by another object of the same class.
2. Return of objects as a function value.
3. An object is passed to a function as a non-reference parameter.
Q. Give the syntax of copy constructor.
Class_Name( Class_Name & obj )
{
// body of constructor
}
Give an example of copy instructor
class A
{ int i; public: A(int a) //constructor
{ i=a; }
A(A &s)//copy constructor
-
8/11/2019 Question on Classes
8/25
Q. Give an example for default constructor
class Defal
{ public: Defal()
{ cout
-
8/11/2019 Question on Classes
9/25
The default constructor initializes the object X1 as constructor is invoked, as soon as the
object is created.
Q. What are the rules for naming destructors?
The rules are:
The destructor must have the same name as the class, preceded by a
tilde (~).
The destructor cannot take arguments therefore cannot be overloaded.
The destructor has no return type.
It should have public access in the class declaration.
Q. List some of the special properties of destructor.
Destructor functions are invoked automatically when the objects are destroyed.
There can be only one destructor for a class, means destructor cant be overloaded.
No argument can be provided to a destructor, neither does it returns any value.
Long answer questions
Q. Explain different types of constructors with examples.
Q. Give the difference between copy and parameterised constructor with example.
Q. Differentiate between a default constructor and copy constructor, giving suitable
examples of each.
Q. Explain default constructor with example
Q. Explain constructor overloading with example.
Q. Differentiate between Constructor and Destructor function with respect to Object
Oriented Programming.
DATA FILE HANDLING
-
8/11/2019 Question on Classes
10/25
Q. What is a file?
A file is an orderly collection of information stored on a secondary storage device.
Q. Mention the need of computer file.
Computer file is used to store large volume of data permanently.
Q. What is an input stream?
The stream that supplies data to the program is known as input stream.
Q. What is an output stream ?
The stream that receives data from the program is known as output stream.
Q. What is the significance of fstream.h file?
In C++ file input output facilities implemented through fstream.h header file.
Q. Name three stream classes commonly used for file I/O.
fstream.h file includes the definitions for the stream classes ifstream, ofstream and fstream.
Q. What is an error stream?
Error stream is basically an output stream used by programs to report error messages or
diagnostics.
Q. Mention the use of filebuf.
It sets the file buffers to read and write.
Q. What is fstreambase
This is the base class for fstream, ifstream and ofstream classes.
Q. What is a datafile?
The file which stores data pertaining to a specific application for later use.
Q. What is a text file?
Text file contains characters.
Q. What is a binary file?
A binary file is a file that contains information in the same format in which the information
is held in memory, i.e., in the binary form.
Q. How to close a file?
Filename.close( ) where Filename is the name of the file.
Q. What are the different ways of opening a file?
1. Using the constructor function of the class.
2. Using the member function open() of the class.
Q. What is a file mode?
A file mode describes how a file is to be used: read it, write to it, append it, and so on.
Q. Give the syntax of open statement.
Stream_Object.open( filename, mode );
Q. Write a code that will create an object called outfile for writing, associate it with thefilename employee.
ofstream outfile;
filout.open("employee");
Q. If we dont mention the mode in the open statement what happens?
ios::in and ios::out are automatically and respectively assumed, even if a mode that does
not include then is passed as second argument to the open( ) function.
Q. When do you think text files should be preferred over binary files?
When file does need to be read by people or need to be ported to a different type of system,
text files should be preferred over binary files.
Q. What is the advantage of saving data in binary form
Binary files are faster and easier for a program to read and write than are text files.
-
8/11/2019 Question on Classes
11/25
Q. Suggest the situation where write() and read() are preferred over get() and put() for file
I/O operations.
The get() and put() functions perform I/O byte by byte. On the other hand, read() and write()
functions let you read and write structures and objects in one go without creating need for
I/O for individual constituent fields.
Q. What is a file pointer?
A file pointer points to a position in a file, which is determined by the offset (number
of bytes) from the beginning or from the end.
Q. Mention different types of file pointers.
1. Input pointer or get pointer
2. Output pointer or put pointer
Q. What is the function of get pointer?
get pointer points to the element to be read in the next input operation.
Q. What is the function of put pointer?
The output pointer is also known as put pointer that points to the location where the nextelement has to be written.
Q. When file is opened in read mode give the position of get pointer.
The position of the get pointer is at beginning of the file.
Q. When file is opened in write mode give the position of get pointer.
The position of the put pointer is at the beginning of the file.
Q. What is the meaning of this statement TextFile.seekp(m,ios::beg)
Move forward put pointer in the TextFile by m bytes from the beginning for writing.
Q.Give the purpose read().
Read() is used read the contents of the binary file associated with ifstream object.
Q.Give the purpose write().
Write() is used write the contents of the binary file associated with ofstream object.
Q. Give the syntax of read().
infile.read( (char *)&variable, sizeof(variable));
Q. Give the syntax of write().
infile.write( (char *)&variable, sizeof(variable));
TYPE B : SHORT ANSWER QUESTIONS & ANSWERS
Q. Discuss the files stream classes defined inside fstream.h header file.
ifstream: can be used for read operations.ofstream: can be used for write operations.
fstream: can be used for both read & write operations.
Q. What are the steps involved in using a file in a C++ program?
In order to process files, follow these steps:
(ii) Declare a stream accordingly.
(iii) Link file with the stream
(iv) Process as required, and
(v) De-link the file with the stream.
Q. Explain construct method of opening a file?
-
8/11/2019 Question on Classes
12/25
This method is useful when only one file is used in the stream. Constructors of the stream
classes ifstream, ofstream and fstream are used to initialize the file stream object with the
file name. For example ifstream read_file(Names.Dat);
Q. Explain open file method.
This method is useful when we want to use different files in the stream. If two or more files
are to be processed simultaneously, separate streams must be declared for each. Forexample,
ifstream ifl; //input stream ifl created
ifl.open(Names.Dat); // file Names.Dat linked with ifl
This method is preferred over first method when there is a situation to open more than one
file.
Q. When a file is opened for output what happens when ) the mentioned file does not exist
and the mentioned file does exist.
It creates a new file and if the file exists the previous contents ill be lost and the output
starts with a fresh file.
Q. What is the difference between get( ) and put( )?The put( ) is a member function of ostream, which is used to write a single
character at a time into the associated stream. Similarly, the get( ) is a member
function of istream, which reads a single character from the associated stream.
Q. What are the different file opening modes?
ios::in Opens file for reading.
ios::out Opens file for writing.
ios::app This causes all output to that file to be appended to the end.
Q. Write a code that will create an object called outfile for writing, associate it with thefilename employee.
ofstream outfile;
filout.open("employee");
Q. Both ios::ate and ios::app place the file pointer at the end of the file when it is opened.
What then, is the difference between them?
Both ios::ate and ios::app place the file pointer at the end of the file when it is opened. The
difference between the two is that ios::app lets you add data to the end of the file only, while
the ios::ate mode when opened with ofstream allows you to write data anywhere in the file,
even over old data.
Q. Why can't we use ordinary pointer in case of files?
Mention the different operations of get pointer.
seekg( ): It moves the file get pointer to location specified by its
arguments.
tellg( ): It returns the current position of the get pointer.
Q. Mention the different operations of get pointer.
seekp( ) : It moves the file put pointer to location specified by its
arguments.
tellp( ) : It returns the current position of the put pointer.
Q. Give the syntax of seekg().
1. seekg (AbsolutePosition);
2. seekg (long offset, RelativePosition);
The AbsolutePosition argument specifies the starting point for the file
-
8/11/2019 Question on Classes
13/25
-
8/11/2019 Question on Classes
14/25
-
8/11/2019 Question on Classes
15/25
void Register();
void Show();
int CheckCode(char AC[])
{ return strcmp(AreaCode,AC); }
};
Q. Write a function COPYABC() in C++, that would copy all those records having AreaCodeas 123 from TELEPHONE.DAT to TELEBACK.DAT.
Q. Write a function in C++ to count the number of digits present in a text file PARA.TXT.
class Consumer
{ char C_Name[20];
char C_Address[30];
char Area[25];
char C_Phone_No[15];
public:
void Ledger();
void Disp();
int checkCode(char AC[]){ return strcmp(Area,AC); }
};
Q. Write a function COPYAREA() in C++, that would copy all those records having Area as
SOUTH from CONSUMER.DAT to BACKUP.DAT.
Q. Given a binary file GAME.DAT, containing records of the following structure type
struct Game
{ char GameName[20];
char Participant[10][30];
};
Write a function in C++ that would read contents from the file GAME.DAT and creates a filenamed BASKET.DAT copying only those records from GAME.DAT where the event name is
Basket Ball.
Q. How is the working of file I/O error handling functions associated with error-status
flags?
Q. What do the following function do?
a. good() b. bad() c. clear() d. fail()
e. eof()
BOOLEAN ALGEBRA
Very short answer questions.
Q. Name the person who developed Boolean algebra.
George boole developed Boolean algebra.
Q. What is the other name of Boolean algebra?
The other name is switching algebra.
Q. What is Boolean algebra?
Boolean algebra deals with set of values 0 and 1.
Q. What is a logical expression?
A logical expression is a string of symbols representinglogical variablesandlogical
operations.Q. What is a truth table?
-
8/11/2019 Question on Classes
16/25
A table of all possible combinations of the variables showing the relation
Q. Mention different logic operations.
The different logic operations arenot, and, or.
Q. How many input combination can be there in the truth table of a logic system having (N)
input binary variables?
There can be 2N input combination in the truth table of a logic system having (N) inputbinary variables.
Q. What is a logic gate?
A logic circuit with one or more input signals but only one output signal.
Q. Name the three basic logic gates.
The three logic gates are NOT,AND,OR.
Q. What is the other name of NOT gate?
INVERTER is the other name.
Q. Write the logic diagram of AND gate.
Q. Write the truth table of AND gate.
Q. Write the logic diagram of OR gate.Q. Write the truth table of OR gate.
Q. Write the logic diagram of NOT gate.
Q. Write the truth table of NOT gate.
Q. Write the logic diagram of NAND gate.
Q. Write the truth table of NAND gate.
Q. Write the logic diagram of NOR gate.
Q. Write the truth table of NOR gate.
Q. Explain the working of AND gate.
An AND gate has two or more input signals but only one output signal. The AND gate
output is equal to the AND product of the logic inputs; that is, F =XY.
Q. Explain the working of OR gate.An OR gate has two or more input signals but only one output signal. The inputs X and Y
are logic voltage level whose value is the result of the OR operation on X and Y; that is,
F=X+Y.
Q. Explain the working of NOT gate.
NOT gate has only one input , and only one output. The output state is always the opposite
of the input state. A NOT gate is also called as INVERTER gate, because the output is not
the same as the input.
Q. What is a postulate?
Fundamental conditions or self-evident propositions are calledpostulates.Q. Mention different universal gates.
NANDand NOR gate are the universal gates.
Q. What is meant by universal gate ?
Any basic gate AND, OR and NOT gate can be realised using universal gate using NAND or
NOR gate.
Q. Explain the working of NAND gate.
The NAND gate is a complemented AND gate. The NAND gate has two or more input signals
but only one output signal. All input signals must be HIGH to get a LOW output.
Q. Explain the working of NOR gate.
The NOR gate is a complemented OR gate. The NOR gate has two or more input signals butonly one output signal. All inputs must be LOW to get a HIGH output.
-
8/11/2019 Question on Classes
17/25
-
8/11/2019 Question on Classes
18/25
Q. Which gates are called Universal gates and why?
NAND and NOR gates are called Universal gates because NAND and NOR gates are less
expensive and easier to design. Also other functions (NOT, AND, OR) can easily be
implemented using NAND/NOR gates.
Q. Write the truth table for (XY + XZ)
X Y Z X.Y X.Z XY + XZ
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 1 1 0 0 0
1 0 0 0 0 0
1 0 1 0 1 1
1 1 0 1 0 1 1 1 1 1 1 1
Q. Simplify the following expression.
(i) ABC (ABC + ABC + ABC) (ii) XY + XYZ + XYZ + XZY
Substitute x=ABCX(X+X+X) we know that X+X=X XY( 1+ Z + Z + Z) 1+Z=1
X(X+X) XY( 1+ Z+Z)
X(X) X.X=X XY( 1+Z)
X substitute X=ABC XY(1)
ABC XY
Q. Simplify Boolean expression AB + ABCD + ABCDE + ABCDEF
AB + ABC + ABCD + ABCDE + ABCDEF
=(AB +ABC) + (ABCD +ABCDE) + ABCDEF (Commutative Law Law)
=AB + ABCD +ABCDEF (Absorption Law)
=AB +( ABCD +ABCDEF) (Commutative Law Law)
=AB +ABCD (Absorption Law)=AB
Q. Simplify the following Boolean expression :
(i) AB + AB+ AC + AC (ii) XY + XYZ + XYZ + XZY (iii) XY(XYZ+ XYZ+ XYZ)
(i) AB + AB + AC + AC
= A(B + B) + A(C + C) (B + B =1, C + C = 1)
= A + A (A + A = 1)
= 1
(ii) XY + XYZ + XYZ + XZY
= XY(Z) + XY(Z + Z) (Z + Z =1)
= XY(Z) + XY
= XY(Z + 1) (Z + 1 = 1)
= XY
(iii) XY(XYZ + XYZ + XYZ)
-
8/11/2019 Question on Classes
19/25
= XY[Z(XY + XY + XY)]
= XY[Z(XY + XY(1 + 1)]
= XY[Z(XY + XY)]
= XYZ(XY + XY)
Q. Simplify the following Boolean expression :(i) AB + AB+ AC + AC (ii) XY + XYZ + XYZ + XZY (iii) XY(XYZ+ XYZ+ XYZ)
(i) AB + AB + AC + AC
= A(B + B) + A(C + C) (B + B =1, C + C = 1)
= A + A (A + A = 1)
= 1
(ii) XY + XYZ + XYZ + XZY
= XY(Z) + XY(Z + Z) (Z + Z =1)
= XY(Z) + XY
= XY(Z + 1) (Z + 1 = 1)
= XY
(iii) XY(XYZ + XYZ + XYZ)= XY[Z(XY + XY + XY)]
= XY[Z(XY + XY(1 + 1)]
= XY[Z(XY + XY)]
= XYZ(XY + XY)
Q. Prove algebraically that X + XY = X + Y.
L.H.S. = X + XY
= X.1 + XY (X . 1 = X property of 0 and 1)
= X(1 + Y) + XY (1 + Y = 1 property of 0 and 1)
= X + XY + XY
= X + Y(X + X)
= X + Y.1 (X + X =1 complementary law)= X + Y (Y . 1 = Y property of 0 and 1)
= R.H.S. Hence proved.
Q. Simplify the following Boolean expression :
(i) AB + AB+ AC + AC (ii) XY + XYZ + XYZ + XZY (iii) XY(XYZ+ XYZ+ XYZ) (i)
AB + AB + AC + AC
= A(B + B) + A(C + C) (B + B =1, C + C = 1)
= A + A (A + A = 1)
= 1
(ii) XY + XYZ + XYZ + XZY
= XY(Z) + XY(Z + Z) (Z + Z =1)= XY(Z) + XY
= XY(Z + 1) (Z + 1 = 1)
= XY
(iii) XY(XYZ + XYZ + XYZ)
= XY[Z(XY + XY + XY)]
= XY[Z(XY + XY(1 + 1)]
= XY[Z(XY + XY)]
= XYZ(XY + XY)
Q. Prove algebraically xyz + xyz + xyz + xyz + xyz + xyz = x + y
LHS = xyz + xyz + xyz + xyz + xyz + xyz
= xy(z + z) + xy(z + z) + xy(z + z) (z + z = 1, z + z = 1)
= xy + xy + xy
-
8/11/2019 Question on Classes
20/25
= x(y + y) + xy
= x + xy (y + y = 1)
= x + (x)y (x = (x))
= x + y (a + ab = a + b x + xy = x + y)
= RHS
Q. Explain the principle of duality theorems in detail.
The derived relation using duality principle is called dual of original expression.
This states that starting with a Boolean relation, another relation can be derived by
1. Changing each OR sign (+) to an AND sign (.)
2. Changing each AND sign (.) to an OR sign (+)
3. Replacing each 0 by 1 and each 1 by 0.
4. All variables are complemented.
Q. Write dual of the following Boolean Expression :
(a) (x + y) (b) xy + xy + xy (c) a + ab + b (d) (x + y + z)(x + y)
(a) xy (b) (x + y)(x + y)(x + y) (c) a . (a + b) . b (d) xyz + xy
Q. Find the complement of the following functions applying DeMorgans theorem
(a) F(x,y,z) = xyz + xyz (b) F(x,y,z) = x(yz + yz)
(a) xyz + xyz (b) x(yz + yz)
= (xyz + xyz) = x + (yz + yz)
= (xyz)(xyz) = x + (y + z)(y + z)
= (x + y + z)(x + y + z) = x + (y + z)(y + z)
= (x + y + z)(x + y + z)
Q. State the distributive laws of Boolean algebra. How do they differ from thedistributive laws of ordinary algebra?
Distributive laws of Boolean algebra state that
(i) X(Y + Z) = XY + XZ
(ii) X + YZ = (X + Y)(X + Z)
1st law X(Y + Z) = XY + XZ holds good for all values of X, Y and Z in ordinary algebra
whereas X + YZ = (X + Y)(X + Z) holds good only for two values (0, 1) of X, Y and Z.
Q. Write the minterm and Maxterm for a function F(x,y,z) when x =0, y = 1, z = 0.
Minterm : xyz Maxterm: x + y + z
Q. Write the minterm and Maxterm for a function F(x,y,z) when x =1, y = 0, z = 0.
Minterm : xyz Maxterm: x + y + z
Q. Write short hand notation for the following minterms : XYZ, XYZ, XYZ
Short hand notation for the minterms XYZ, XYZ, XYZ is F = (2, 3, 7)
Q. Write short hand notation for the following maxterms : X + Y + Z, X + Y+ Z, X+ Y
+ Z, X + Y+ Z
Short hand notation for the maxterms X + Y + Z, X + Y+ Z, X+ Y + Z, X + Y+ Z
F = (0, 2, 3, 5)
Q. What is the Boolean expression, containing only the sum of minterms, called?
The Boolean expression, containing only the sum of minterms, is called Canonical
Sum- of Product Form of an expression.
-
8/11/2019 Question on Classes
21/25
Q. What is the Boolean expression, containing only the product of Maxterms, called?
The Boolean expression, containing only the product of Maxterms, is called
Canonical Product- of Sum Form of an expression.
Q. State the purpose of reducing the switching functions to the minimal form?
The switching functions are practically implemented in the form of gates. Aminimized Boolean expression means less number of gates which means simplified
circuitary. Thus, the purpose of reducing the switching functions to the minimal
form is getting circuitary.
Q. What do you mean by canonical form of a Boolean expression? Which of the
following are canonical? (i) ab + bc (ii) abc + abc+ abc (iii) (a + b)(a +b)
(iv) (a + b + c)(a + b+ c)(a + b +c) (v) ab + bc + ca
Boolean Expression composed entirely either of Minterms or maxterms is referred to
as canonical form of a Boolean expression.
(i)Non canonical (ii) canonical (iii) canonical (iv) canonical (v)
Non canonical
Q. Give an example for each of the following :(i) a boolean expression in the sum of minterm form
(ii) a boolean expression in the non canonical form.
For a function F(X, Y, Z)
(i) Sum of minterms expression is
XYZ + XYZ + XYZ + XYZ
(ii) Non canonical form of Sum-of-products
XY + YZ + ZX+ XY
Q. What are the fundamental products for each of the input words ABCD = 0010.
ABCD = 1101, ABCD = 1110?
The fundamental products for each of the input words ABCD = 0010. ABCD = 1101,
ABCD = 1110 are as following : ABCD + ABCD + ABCD
Q. Construct a boolean function of three variables p, q and r that has an output 1
when exactly two of p, q, r are having values 0, and an output 0 in all other cases.
p q r F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 01 1 0 0
1 1 1 0
F = pqr + pqr+ pqr
Q. Write the Boolean expression for a logic network that will have a 1 output when
X = 1, Y = 0, Z = 0; X = 1, Y = 0, Z = 1; X = 1, Y = 1, Z = 0; and X = 1, Y = 1, Z = 1.
X = 1, Y = 0, Z = 0 XYZ
X = 1, Y = 0, Z = 1 XYZ
X = 1, Y = 1, Z = 0 XYZ
X = 1, Y = 1, Z = 1 XYZ
The Boolean expression is F = XYZ+ XYZ + XYZ + XYZ
-
8/11/2019 Question on Classes
22/25
Q. A truth table has output 1s for each of these inputs :
(a)ABCD = 0011 (b) ABCD = 0101 (c) ABCD = 1000, what are the fundamental
products?
The fundamental products are ABCD + ABCD + ABCD
Output 1s appear in the truth table for these input conditions: ABCD = 0001, ABCD
= 0110, and ABCD = 1110. What is the sum-of-products equation?
ABCD = 0001 = ABCD ABCD = 0110 = ABCD ABCD = 1110 = ABCD
The sum-of-products equation is as following :
F = ABCD + ABCD + ABCD
Q. Derive the Boolean algebra expression for a logic network that will have outputs 0
only output when
X = 1, Y =1, Z = 1; X = 0, Y = 0, Z = 0; X = 1, Y = 0, Z = 0. The outputs are to be 1for all other cases.
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 1
1 1 0 1
1 1 1 0
F = (X + Y + Z)(X + Y + Z)(X + Y +Z)
Convert the expression to canonical Sum-of-Product form X + XY + XZ
= X(Y + Y)(Z + Z) + XY(Z + Z) + XZ(Y + Y)
= (XY + XY)(Z + Z) + XYZ + XYZ + XYZ + XYZ
= Z(XY + XY) + Z(XY + XY) + XYZ + XYZ + XYZ + XYZ
= XYZ + XYZ + XYZ + XYZ + XYZ + XYZ + XYZ + XYZ
By removing duplicate terms we get canonical Sum-of=Product form : XYZ + XYZ +
XYZ + XYZ + XYZ + XYZ + XYZ
F = (1, 2, 3, 4, 5, 6, 7)
F = m1 + m2 + m3 + m4 + m5 + m6 + m7
Q. Convert the expression to canonical Sum-of-Product form YZ + XY
= YZ(X + X) + XY(Z + Z)
= XYZ + XYZ + XYZ + XYZ
By removing duplicate terms we get canonical Sum-of=Product form : XYZ + XYZ +
XYZ
F = (2, 3, 7)
F = m2 + m3 + m7
Q. Draw a logic circuit diagram using AND and OR only to implement the Boolean
function
F(a,b) = ab + ab
-
8/11/2019 Question on Classes
23/25
Q. Draw logic circuit diagrams for the following :
(i) xy + xy + xz (ii) (A + B)(B + C)(C + A) (iii) AB + BC (iv) xyz + xyz
Q. Using the Karnaugh technique obtain the simplified expression as sum of products forthe following map.
Completing the given K-map We have 1 group which is Quad i.e., m2 + m3 + m6 +
m7
= XYZ + XYZ + XYZ + XYZ
= XY(Z + Z) + XY(Z + Z)
= XY + XY
=Y(X + X)= Y
Simplified Boolean expression as sum of products for given K-map is
F(X, Y, Z) = Y.
Q. Draw and simplify the Karnaugh Map of X, Y, Z for m0 + m1 + m5 + m7
Mapping the given function in a K-map, we get 2 Pairs i.e., Pair-1 is m0 + m1
and Pair-2 is m5 + m7
= XYZ + XYZ + XYZ + XYZ
= XY(Z + Z) + XZ(Y + Y)
= XY + XZ
Simplified Boolean expression for given K-map is F(X, Y, Z) = XY + XZ.
Q. Draw and simplify the Karnaugh Map of X, Y, Z for F = (1, 3, 5, 4, 7)
Mapping the given function in a K-map, we get 1 Pair and 1 Quad i.e., Pair is m4 +m5 and Quad is m1 + m3 + m5 + m7
= XYZ + XYZ + XYZ + XYZ + XYZ + XYZ
= XZ(Y + Y) + XZ(Y + Y) + XY(Z + Z)
= XZ + XZ + XY
= Z(X + X) + XY
= Z + XY
Simplified Boolean expression as for given K-map is F(X, Y, Z) = Z + XY.
Q. Draw and simplify the Karnaugh Map of X, Y, Z for m0 +m2 + m4 + m6
Mapping the given function in a K-map, we get 2 Pairs i.e.,
Pair-1 is m0 + m4 and Pair-2 is m2 + m6
= XYZ + XYZ + XYZ + XYZ
-
8/11/2019 Question on Classes
24/25
= YZ(X + X) + YZ(X + X)
= YZ + YZ
= Z(Y + Y)
= Z
Simplified Boolean expression for given K-map is F(X, Y, Z) = Z.
Reduce the following Boolean expression using K-map
F(A, B, ,C, D) = (0,2,3,4,5,6,7,8,10,12)
There are 1 Pair and 2 Quads that reduce as given below:
Pair(m8 + m10) reduces to ABD
Quad-1(m0 + m4 + m12 + m8) reduces to CD
Quad- 2(m2 + m3 + m6 + m7) reduces to AC
Simplified Boolean expression for given K-map isF(A,B,C,D) = ABD + CD + AC
Obtain a simplified form for a Boolean expression :
F(X, Y, Z, W) = (0, 1, 4, 5, 7, 8, 9, 12, 13, 15) using K-map method.
There are 1 Pair and 1 Octet that reduce as given below: Pair(m7 + m15) reduces to
YZW
Octet(m0 + m1 + m4 + m5 + m8 + m9 + m12 + m13) reduces to Z
Simplified Boolean expression for given K-map is
F(X,Y,Z,W) = YZW + Z
Long answer questionsQ. What is meant by universal gates? Realise AND, OR and NOT gates using
NAND and NOR gates.
Q. State all the postulates of boolean algebra.
Q. State and verify De Morgans law in Boolean Algebra.
Q. Explain the functioning of basic gates with truth table and example.
Q. State the distributive law. Verify the law using truth table.
Q. Distributive law state that (a) X(Y +Z) = XY + XZ (b) X + YZ = (X + Y)(X + Z)
Q. Prepare a table of combination for the following boolean algebra
expressions :(i) ABC + AB (ii) XZ + XY + XZ (iii) ABC + AC + AB
Q. Write the dual form for the following expression
(i) X + XY = X + Y (ii) 1 + X = 1 (iii) X + X = X
(iv) X .X = 0 (v) X + XY = X
Q. Given the following truth table, derive a sum of product (SOP) and Product of
Sum (POS) form of Boolean expression from it :
A B C G(A, B, C)
0 0 0 0
0 0 1 1
0 1 0 10 1 1 0
-
8/11/2019 Question on Classes
25/25