You are on page 1of 25

Very short answer questions

Q. What is the purpose of a class defnition?
A class defnition describes how objects of a class will look when they are created.
Q. What is a class?
A class is a collection of objects that have the identical properties, common behaviour, and
shared relationship.
Q. What are class members?
It is a component of a class. Class members may be either data or functions.
Q. What do you mean by access specifer?
Access specifer controls the access of data members.
Q. Mention diferent access specifers
They are private, public and protected.
Q. To whom can we apply the access specifers?
We can apply them to data members and methods of a class. They cannot be applied to
ordinary variables of functions which are defned outside the class.
Q. How data hiding is done?
Data hiding is done through access specifers
Q. Which is a default access specifer for members of class in C++.
Private is the access specifer by default.
Q. What do you mean by a public member?
A member declared as public member can be accessed freely in a program.
Q. What are the restrictions on private members?
We cannot access private members anywhere in the program. Only methods defned in the
class (both private and public) can access private members.
Q. Do public and private declarations have an efect on calling methods?
Yes. Just like private member variables, private methods cannot be called outside the class.
It does not imply that private methods are unusable. Private as well as public methods of
the class can use them. (It may be noted that public methods can be called from anywhere.)
Q. What are data members?
They are used to describe the properties (characteristics or attributes) of the object under
consideration.
Q. What are member functions or methods?
They are used to describe the operations that can be performed with the data members of
the class. They are able to access even private data members.
Q. What are the diferent ways of declaring member functions?
Member functions can be defned in two places one is inside and other is outside class
declaration.
Q. What is an inline function?
Member functions defned inside the class defnition are created as inline functions by
default.
Q. What is scope resolution operator?
It is used defne member functions outside the class.
Q. Give the symbol of scope resolution operator.
:: is the symbol of scope resolution operator.
Q. What is an object?
An object is an instance of a class.
Q. What is the diference between Object and Instance?
An instance of a user-defned type is called an object. We can instantiate many objects from
one class. An object is an instance of a class.
Q. In c++ object of the class is also called?
Instance
Q. What are instance variables?
Objects are sometimes called instance variables.
Q. How to access class members?
ObjectName. DataMember
Q. Defne accessor functions.
A member function of a class that only accesses i.e., does not modify the values of the
member variables.
Q. Defne mutator function.
A member function of a class that modifes the values of the member variables.
Q. Is member function considered for determining the size of the object?
No.
Q. Which function is used to fnd the size of the object?
Sizeof() is used.
Q. Can an array of objects be created?
Yes.
Q. Can objects be passed to function as a parameter?
Yes.
Q. What are the basic ways of passing an object as a parameter?
Same as in C++ functions. Passing by value and passing by reference.
Q. Can functions return objects?
Yes.
Short answer questions
Q. How do we create a class defnition?
We study a real-life object and its attributes are made as the data members of the class. A
careful study is made of the functions required to access and process the data members.
These functions are then made as the method members of the class.
Q. Can we use the same function name for a member function of a class and an outside i.e.,
a non-member function in the same program fle? If yes, how are they distinguished?
Yes. Object of the class is used to distinguish between the member function of a class and a
non-member function with same name.
Q. Give the general syntax of class declaration.
class Class-Name
{
private : // private data and functions
protected : // protected data and functions

public : // public data and functions
};
Q. Explain private access specifer.
The class members (data and functions) written under this section are accessible by class
member functions or friend functions. The data members or member functions declared
private cannot be accessed from outside the class. The objects of the class can access the
private members only through the public member functions of the class.
Q. Explain public access specifer.
The class members declared in this section are accessible from inside or outside the class.
Some of the public functions of a class provide interface for accessing the private and
protected members of the class.
Q. Explain protected access specifer
The class members of this section are accessible by thefunction members of same class and
friend functions or friend classes as well as by functions of derived classes. For all other
operations protected members are similar to private members.
Q. Explain scope resolution operator
It is used to defne member function outside the class. Only the scope resolution operator
identifes the function as a member of a particular class. Without this scope resolution
operator, the function will be treated as an ordinary function.
Q. What do you mean by nesting member functions?
A member function within another member function is called nesting of member function.
Q. Write a short note on memory allocation of class and its objects.
When a class is defned, memory is allocated for its member functions and they are stored
in the memory. When an object is created, separate memory space is allocated for its data
members. All objects work with the one copy of member function shared by all.
Long answer questions
Q. Describe the mechanism of accessing data members and member functions in the
following cases.
(a) Inside the main program.
(b) Inside a member function of the same class.
(c) Inside a member function of another class.
Q. Can we use the same function name for a member function of a class and an outside
function in the same program fle ? If yes. how are they distinguished ? If no, give
reasons.
Q. How do you nest member function ? Explain with examples.
Q. How are arrays defned within a class ? Illustrate with an example.
Q. How is an array of objects defned ? Describe with an example.
Q. How are objects passed to a function ? Illustrate with suitable example.
Q. Defne the class point having the two integer type data members x and y (x and y co-
ordinates in two-dimensional plane), and a member function to fnd the distance
between two given points.
Q. Declare the class complex having two foating point type data members called
real and imaginary, and a member functions to fnd the absolute value of a
given complex number.
Q. Declare the class time having three integer type data members hours, minutes
and seconds, and a member functions to fnd the total time for a given set of
time.
Q. Declare the class date having three integer type data members day. month and
year, and a member function to fnd the number of days between two given dates.
Declare the class student having the data members name, roll number,
total marks, and two member functions one to get the data and the other to
display the data.
Q. Declare the class bank account having name, account number, balance,
and four member functions to open an account, deposit in the account, withdraw
from the account and display account balance.
Define a class to represent a book in a library. Include the following members:
Data Members
Book Number, Book Name, Author, Publisher, Price, No. of copies issued, No. of copies
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 sixes
Member Functions:
(i) To assign the initial values
(ii) To update runs made .
(iii) To display the batsman’s 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<<"error";}
public:
void Xdata(int d) {some=d;more=d++; }
void Ydata() {cout<<some<<" "<<more; }
};
(i) Write the name that specifes the above class.
(ii) Write the data of the class with their access scope.
(iii) Write all member functions of the class along with their access scope.
(iv) Indicate the member function of the SmallObj that sets data.
CONSTRUCTOR AND DESTRUCTOR QUESTIONS
Very short answer questions
Q. Defne 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++ compiler
without any argument for initialising the objects of a class.
Q. Defne a parameterised constructor.
The constructor that can take arguments are called parameterized constructor.
Q. What is the signifcance 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 doesn’t return any value.
Q. Give the syntax of defning a constructor.
class ClassName
{ {
Private:................
public :
ClassName ( ) {
............... }
Q. Mention the diferent types of constructors.
Constructors are normally classifed 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
Q. Give an example for default constructor
class Defal
{ public: Defal()
{ cout<<" Default constructor";
}
Q. What is the signifcance of copy constructor? Which situation is it invoked in?
The copy constructor is used to Initialize one object from another of the same type.
It is invoked to copy an object to pass it as an argument to a function.
Copy an object to return it from a function.
Q. Explain constructor overloading
One of the important features of the constructors is that a class can have two or more
constructors. This is called constructor overloading. The overloading constructor is an
important concept in object-oriented-programming in which the same constructor name is
called with diferent arguments. Depending upon the type of argument, the constructor will
be invoked automatically by the compiler to initialise the objects.
Q. Consider the following code:
class ci
{ int l;
public:
ci(int j) { l=j; }
ci(ci &rv) { l=rv.l; }
void initialize() { l=0; }
};
main()
{ ci original(1);
ci X1(original);
ci X2=original;
}
Referring to the sample code above, what initializes the object X1?
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 can’t be overloaded.
No argument can be provided to a destructor, neither does it returns any value.
Long answer questions
Q. Explain diferent types of constructors with examples.
Q. Give the diference between copy and parameterised constructor with example.
Q. Diferentiate 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. Diferentiate between Constructor and Destructor function with respect to Object
Oriented Programming.
DATA FILE HANDLING
Q. What is a fle?
A fle is an orderly collection of information stored on a secondary storage device.
Q. Mention the need of computer fle.
Computer fle 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 signifcance of fstream.h fle?
In C++ fle input output facilities implemented through fstream.h header fle.
Q. Name three stream classes commonly used for fle I/O.
fstream.h fle includes the defnitions 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 flebuf.
It sets the fle bufers to read and write.
Q. What is fstreambase
This is the base class for fstream, ifstream and ofstream classes.
Q. What is a datafle?
The fle which stores data pertaining to a specifc application for later use.
Q. What is a text fle?
Text fle contains characters.
Q. What is a binary fle?
A binary fle is a fle 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 fle?
Filename.close( ) where Filename is the name of the fle.
Q. What are the diferent ways of opening a fle?
1. Using the constructor function of the class.
2. Using the member function open() of the class.
Q. What is a fle mode?
A fle mode describes how a fle is to be used: read it, write to it, append it, and so on.
Q. Give the syntax of open statement.
Stream_Object.open( flename, mode );
Q. Write a code that will create an object called outfle for writing, associate it with the
flename employee.
ofstream outfle;
flout.open("employee");
Q. If we don’t 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 fles should be preferred over binary fles?
When fle does need to be read by people or need to be ported to a diferent type of system,
text fles should be preferred over binary fles.
Q. What is the advantage of saving data in binary form
Binary fles are faster and easier for a program to read and write than are text fles.

Q. Suggest the situation where write() and read() are preferred over get() and put() for fle
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 felds.
Q. What is a fle pointer?
A fle pointer points to a position in a fle, which is determined by the ofset (number
of bytes) from the beginning or from the end.
Q. Mention diferent types of fle 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 next
element has to be written.
Q. When fle is opened in read mode give the position of get pointer.
The position of the get pointer is at beginning of the fle.
Q. When fle is opened in write mode give the position of get pointer.
The position of the put pointer is at the beginning of the fle.
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 fle associated with ifstream object.
Q.Give the purpose write().
Write() is used write the contents of the binary fle associated with ofstream object.
Q. Give the syntax of read().
infle.read( (char *)&variable, sizeof(variable));
Q. Give the syntax of write().
infle.write( (char *)&variable, sizeof(variable));
TYPE B : SHORT ANSWER QUESTIONS & ANSWERS
Q. Discuss the fles stream classes defned inside fstream.h header fle.
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 fle in a C++ program?
In order to process fles, follow these steps:
(ii) Declare a stream accordingly.
(iii) Link fle with the stream
(iv) Process as required, and
(v) De-link the fle with the stream.
Q. Explain construct method of opening a fle?
This method is useful when only one fle is used in the stream. Constructors of the stream
classes ifstream, ofstream and fstream are used to initialize the fle stream object with the
fle name. For example ifstream read_fle(“Names.Dat”);
Q. Explain open fle method.
This method is useful when we want to use diferent fles in the stream. If two or more fles
are to be processed simultaneously, separate streams must be declared for each. For
example,
ifstream if; //input stream if created
if.open(“Names.Dat”); // fle Names.Dat linked with if
This method is preferred over frst method when there is a situation to open more than one
fle.
Q. When a fle is opened for output what happens when ) the mentioned fle does not exist
and the mentioned fle does exist.
It creates a new fle and if the fle exists the previous contents ill be lost and the output
starts with a fresh fle.
Q. What is the diference 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 diferent fle opening modes?
ios::in Opens fle for reading.
ios::out Opens fle for writing.
ios::app This causes all output to that fle to be appended to the end.
Q. Write a code that will create an object called outfle for writing, associate it with the
flename employee.
ofstream outfle;
flout.open("employee");
Q. Both ios::ate and ios::app place the fle pointer at the end of the fle when it is opened.
What then, is the diference between them?
Both ios::ate and ios::app place the fle pointer at the end of the fle when it is opened. The
diference between the two is that ios::app lets you add data to the end of the fle only, while
the ios::ate mode when opened with ofstream allows you to write data anywhere in the fle,
even over old data.
Q. Why can't we use ordinary pointer in case of fles?
Mention the diferent operations of get pointer.
seekg( ): It moves the fle get pointer to location specifed by its
arguments.
tellg( ): It returns the current position of the get pointer.
Q. Mention the diferent operations of get pointer.
seekp( ) : It moves the fle put pointer to location specifed 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 ofset, RelativePosition);
The AbsolutePosition argument specifes the starting point for the fle
pointer. The ofset argument can be any integer type, and may be positive or negative.
The RelativePosition argument specifes the starting point for the ofset, i.e., from fle
beginning, from the current position of fle pointer or from fle end.
Q. What are the diferent relative positions?
The three RelativePosition are
ios::beg From the beginning of fle
ios::cur From current position of fle
ios::end From the end of fle
Q. Give the syntax of seekp.
1. seekp (AbsolutePosition);
2. seekp (long ofset, RelativePosition);
The AbsolutePosition argument specifes the starting point for the fle
pointer. The ofset argument can be any integer type, and may be positive or negative.
The RelativePosition argument specifes the starting point for the ofset, i.e., from fle
beginning, from the current position of fle pointer or from fle end.
Q. Give the diference between tellg and tellp.
tellg( ) It returns the current position of the get pointer.
tellp( ) It returns the current position of the put pointer.
Q. Give the diference between seekg() and seekp() pointer
seekg( ) It moves the fle get pointer to location specifed by its arguments. This pointer is
used for reading.
seekp( ) It moves the fle put pointer to location specifed by its arguments. This pointer is
used for reading.
Q. Why error handling is required in case of fles?
The stream I/O operations are prone to errors which may be due to programmer or due to
constraints of the hardware such as insufcient memory or due to user. In such case error
handling is required.
4
Q. Write statements using seekg() to perform the following:
To move the pointer by 15 positions backward from current position.
infle.seekg(15,ios::cur)
To goto byte number 40 in the fle.
infle.seekg(40,ios::beg)
To go backward by 30 bytes from the end.
infle.seekp(-30,ios::end)
Q. Give the purpose of bad().
bad( ) returns TRUE if a reading or writing operation fails. For example, if we try to write to
a fle that is not open for writing or if the device where we are trying to write has no
space left.
Q. Give the pupose of fail().
fail( ) returns TRUE in the same case as bad( ), but also in the case that a format error
happens, like when an alphabetical is extracted when we are trying to read an integer
number.
Q. Give the pupose of eof().
eof( ) Returns TRUE, (non-zero value) if end-of-fle is encountered while reading; FALSE,
(zero) otherwise.
Q. Give the pupose of good().
function ofgood( ) It is the most generic state fag. This function returns TRUE if no error
has occurred. This means, all the above functions are FALSE. For example, if File.good() is
true, every thing is good and can be proceed for further processing.
Q. Give the pupose of clear().
clear( ) Resets error states set by the above functions and further operations can be
attempted.
Long answer questions.
Q. Explain diferent stream supported in C++.
Q. Explain diferent type of fles.
Q. What role is played by fle modes in fle operations? Describe the various fle mode
constants and their meanings.
Q. What do you understand by following fle opening modes?
a. ios::binary b. ios::out c. ios::in
d. ios::ate e. ios::beg f. ios::end
g. ios::app
Q. Write a program that reads a text fle and creates another fle that is identical expect
that every sequence of consecutive blank space is replaced by a single space.
Q. Given a binary fle SPORTS.DAT, containing records of the following structure type:
struct Sports
{ char Event[20];
char Participant[10][30];
};
Q. Write a function in C++ that would read contents from the fle SPORTS.DAT and creates
a fle named ATHLETIC.DAT copying only those records from SPORTS.DAT where the event
name is “Athletics”.
Q. Write a function in C++ to count the words to and the present in a text fle “POEM.TXT”.
“TRAIN.DAT”. Assuming the binary fle is containing the objects of the following class.
class TRAIN
{
int Tno; // Train Number
char From[20]; // Train Starting Point
char To[20]; // Train Destination
public:
char* GetFrom (){return From;}
char* GetTo (){return To;}
void Input () {cin>>Tno;gets(From);gets(To);}
void Show () {cout<<Tno<<:<<From<<:<<To<<endl;}
};
Q. Given a binary fle TELEPHON.DAT, containing records of the following class Directory:
class Directory
{ char Name[20];
char Address[30];
char AreaCode[5];
char Phone_No[15];
public:
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 AreaCode
as “123” from TELEPHONE.DAT to TELEBACK.DAT.
Q. Write a function in C++ to count the number of digits present in a text fle “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 fle 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 fle GAME.DAT and creates a fle
named BASKET.DAT copying only those records from GAME.DAT where the event name is
“Basket Ball”.
Q. How is the working of fle I/O error handling functions associated with error-status
fags?
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 representing logical variables and logical
operations.
Q. What is a truth table?
A table of all possible combinations of the variables showing the relation
Q. Mention diferent logic operations.
The diferent logic operations are not, 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) input
binary 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 called postulates.
Q. Mention diferent universal gates.
NAND and 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 but
only one output signal. All inputs must be LOW to get a HIGH output.
Q. Realise OR gate using NOR gates.
Q. Realise AND gate using NAND gates.
Q. State any two postulates of boolean algebra.
X + 0 = X, X . 1 = X
Write the dual of :
a) 0 + 0 = 0
b) 0 + 1 = 1
c) 1 + 0 = 1
d) 1 + 1 = 1
0.0 = 0
0.1=0
1.0=0
1.1=1
Q. What is meant by proof by perfect induction?
In Boolean algebra, it is possible to test the validity of the theorems by substituting all
possible values of the variables because the variables have only two values, viz. 0 and 1.
This technique of proving theorems is known as proof by perfect induction.
Q. State Demorgans theorem.
When the OR sum of two variables is inverted, this is the same as inverting each variable
individually and then ANDing these inverted variables.
Q. What is min term?
A single variable or the logical product of several variables. The variables may or may not be
complemented.
Q. What is SOP?
A sum-of-product expression is a product term or several product logically added.
Q. What is max term?
A single variable or the logical sum of several variables. The variables may or may not be
complemented.
What is POS?
A product-of-sum expression is a sum term or several sum terms logically multiplied.
Q. What is fundamental product?
The logical product of variables and complements that produces a high output for a given
input condition.
Q. What is k map?
A graphical display of the fundamental products in a truth table.
Q. What is a subcube?
A subcube is a set of exactly 2m adjacent squares containing 1s.
Q. What is a pair?
A subcube of two adjacent 1s on a Karnaugh map. These 1s may be horizontally or
vertically aligned.
Q. What is a quad?
A group of four adjacent 1s on a Karnaugh map.
Q. What is an octet?
A group of eight adjacent 1s on a Karnaugh map.
Short answer questions.
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=ABC
X(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’+ A’C + A’C’ (ii) XY + XYZ’ + XYZ’ + XZY (iii) XY(X’YZ’+ XY’Z’+ XY’Z’)
(i) AB + AB’ + A’C + A’C’
= 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(X’YZ’ + XY’Z’ + XY’Z’)
= XY[Z’(X’Y + XY’ + XY’)]
= XY[Z’(X’Y + XY’(1 + 1)]
= XY[Z’(X’Y + XY’)]
= XYZ’(X’Y + XY’)
Q. Simplify the following Boolean expression :
(i) AB + AB’+ A’C + A’C’ (ii) XY + XYZ’ + XYZ’ + XZY (iii) XY(X’YZ’+ XY’Z’+ XY’Z’)
(i) AB + AB’ + A’C + A’C’
= 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(X’YZ’ + XY’Z’ + XY’Z’)
= XY[Z’(X’Y + XY’ + XY’)]
= XY[Z’(X’Y + XY’(1 + 1)]
= XY[Z’(X’Y + XY’)]
= XYZ’(X’Y + XY’)
Q. Prove algebraically that X + X’Y = X + Y.
L.H.S. = X + X’Y
= X.1 + X’Y (X . 1 = X property of 0 and 1)
= X(1 + Y) + X’Y (1 + Y = 1 property of 0 and 1)
= X + XY + X’Y
= 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’+ A’C + A’C’ (ii) XY + XYZ’ + XYZ’ + XZY (iii) XY(X’YZ’+ XY’Z’+ XY’Z’) (i)
AB + AB’ + A’C + A’C’
= 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(X’YZ’ + XY’Z’ + XY’Z’)
= XY[Z’(X’Y + XY’ + XY’)]
= XY[Z’(X’Y + XY’(1 + 1)]
= XY[Z’(X’Y + XY’)]
= XYZ’(X’Y + XY’)
Q. Prove algebraically x’y’z’ + x’y’z + x’yz + x’yz’ + xy’z’ + xy’z = x’ + y’
LHS = x’y’z’ + x’y’z + x’yz + x’yz’ + xy’z’ + xy’z
= x’y’(z’ + z) + x’y(z + z’) + xy’(z’ + z) (∵ z’ + z = 1, z + z’ = 1)
= x’y’ + x’y + xy’
= x’(y’ + y) + xy’
= x’ + xy’ (∵ y’ + y = 1)
= x’ + (x’)’y’ (∵ x = (x’)’)
= x’ + y’ (∵ a + a’b = 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’ + x’y (c) a + a’b + b’ (d) (x + y’ + z)(x + y)
(a) xy’ (b) (x + y)(x + y’)(x’ + y) (c) a . (a’ + b) . b’ (d) xy’z + xy
Q. Find the complement of the following functions applying De’Morgan’s theorem
(a) F(x,y,z) = x’yz’ + x’y’z (b) F(x,y,z) = x(y’z + yz)
(a) x’yz’ + x’y’z (b) x(y’z + yz)
= (x’yz’ + x’y’z)’ = x’ + (y’z + yz)’
= (x’yz’)’(x’y’z)’ = 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 difer from the
distributive 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 : x’yz’ 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 : xy’z’ Maxterm: x’ + y + z
Q. Write short hand notation for the following minterms : XYZ, X’YZ’, X’YZ
Short hand notation for the minterms XYZ, X’YZ’, X’YZ 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.
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. A
minimized Boolean expression means less number of gates which means simplifed
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 + a’bc’+ ab’c’ (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 + X’Y’Z + X’Y’Z + XYZ’
(ii) Non canonical form of Sum-of-products
XY + Y’Z + ZX’+ X’Y’
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 : A’B’CD’ + ABC’D + 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 0
1 1 0 0
1 1 1 0
F = p’q’r + p’qr’+ pq’r’
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 XY’Z’
X = 1, Y = 0, Z = 1 XY’Z
X = 1, Y = 1, Z = 0 XYZ’
X = 1, Y = 1, Z = 1 XYZ
The Boolean expression is F = XY’Z’+ XY’Z + XYZ’ + XYZ
Q. A truth table has output 1’s for each of these inputs :
(a)ABCD = 0011 (b) ABCD = 0101 (c) ABCD = 1000, what are the fundamental
products?
The fundamental products are A’B’CD + A’BC’D + AB’C’D’
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 = A’B’C’D ABCD = 0110 = A’BCD’ ABCD = 1110 = ABCD’
The sum-of-products equation is as following :
F = A’B’C’D + A’BCD’ + 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 1
for 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 + X’Y + X’Z’
= X(Y + Y’)(Z + Z’) + X’Y(Z + Z’) + X’Z’(Y + Y’)
= (XY + XY’)(Z + Z’) + X’YZ + X’YZ’ + X’YZ’ + X’Y’Z’
= Z(XY + XY’) + Z’(XY + XY’) + X’YZ + X’YZ’ + X’YZ’ + X’Y’Z’
= XYZ + XY’Z + XYZ’ + XY’Z’ + X’YZ + X’YZ’ + X’YZ’ + X’Y’Z’
By removing duplicate terms we get canonical Sum-of=Product form : XYZ + XY’Z +
XYZ’ + XY’Z’ + X’YZ + X’YZ’ + X’Y’Z’
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 + X’Y
= YZ(X + X’) + X’Y(Z + Z’)
= XYZ + X’YZ + X’YZ + X’YZ’
By removing duplicate terms we get canonical Sum-of=Product form : XYZ + X’YZ +
X’YZ’
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) = a’b’ + ab
Q. Draw logic circuit diagrams for the following :
(i) xy + xy’ + x’z (ii) (A + B)(B + C)(C’ + A’) (iii) A’B + BC (iv) xyz + x’yz’
Q. Using the Karnaugh technique obtain the simplifed expression as sum of products for
the following map.
Completing the given K-map We have 1 group which is Quad i.e., m2 + m3 + m6 +
m7
= X’YZ + X’YZ’ + XYZ + XYZ’
= X’Y(Z + Z’) + XY(Z + Z’)
= X’Y + XY
=Y(X’ + X)
= Y
Simplifed 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
= X’Y’Z’ + X’Y’Z + XY’Z + XYZ
= X’Y’(Z’ + Z) + XZ(Y’ + Y)
= X’Y’ + XZ
Simplifed Boolean expression for given K-map is F(X, Y, Z) = X’Y’ + 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
= X’Y’Z + X’YZ + XY’Z + XYZ + XY’Z’ + XY’Z
= X’Z(Y’ + Y) + XZ(Y’ + Y) + XY’(Z’ + Z)
= X’Z + XZ + XY’
= Z(X’ + X) + XY’
= Z + XY’
Simplifed 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
= X’Y’Z’ + XY’Z’ + X’YZ’ + XYZ’
= Y’Z’(X’ + X) + YZ’(X’ + X)
= Y’Z’ + YZ’
= Z’(Y’ + Y)
= Z’
Simplifed 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 AB’D’
Quad-1(m0 + m4 + m12 + m8) reduces to C’D’
Quad- 2(m2 + m3 + m6 + m7) reduces to A’C
Simplifed Boolean expression for given K-map is
F(A,B,C,D) = AB’D’ + C’D’ + A’C
Obtain a simplifed 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’
Simplifed Boolean expression for given K-map is
F(X,Y,Z,W) = YZW + Z’
Long answer questions
Q. 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 Morgan’s 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 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1
Q. Write the POS form of a Boolean function F, which is represented in a truth table as
follows:
A B C F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
Q. Draw logic circuit for the following using k-maps :
(i) F(A, B, C, O) = ∑(1, 3, 5, 9, 10) (ii) F(A, B, C) = π(0, 2, 4, 5)
(iii) F(A, B, C) = ∑(1, 2, 4, 6, 7) (iv) F(A, B, C) = π(1, 3, 5, 7)
Q. For the logic function of F(A, B, C, D) = ∑(0, 1, 3, 4, 5, 7, 8, 10, 12, 14, 15).
(a) Show the truth table (b) Write the SOP form (c) Write the POS form (d) Simplify by
K-map.
Q. Reduce the following Boolean expression using K-map
F(A, B, ,C, D) = ∑(0,2,3,4,5,6,7,8,10,12)
Q. Reduce the following Boolean expression using K-map : F(A, B, C, D) = (5, 6, 7, 8, 9, 12, ∏
13, 14, 15)
Q. Obtain a simplifed form for a Boolean expression :
F(u, v, w, z) = ∑(0, 1, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15( using Karnaugh Map.
Q. Obtain a simplifed form for a Boolean expression
F(U, V, W, Z) = ∑(0, 1, 3, 4, 5, 6, 7, 9, 10, 11, 13, 15) using Karnaugh Map.