Sunteți pe pagina 1din 88

ON

“LOGIC
SIMPLIFICATION”

SUBMITTED IN PARTIALLY FULFIFLMENT OF THE DIPLOMA


IN

COMPUTER ENGINEERING
Project Submitted To:- Mrs.Anupam
Garg(HOD)
Ms. Monika Gupta
Lect. Ms. Rupinder Kaur
Pr
oject Submitted by: -
PRIYANKA GUPTA
2008/182
RISHI ARORA
2008/187
SHIVANI ARORA
2008/194
(6TH COMP.)

Thapar Polytechnic College,


Patiala.

ACKNOWLEDGEMENT

We feel immense pleasure in submitting this report on


“LOGIC SIMPLIFICATION” . We avail the opportunity in
acknowledging to that entire individual who have directly or indirectly
contribute toward the completion of this project.
We are grateful to respected teachers for their moral Support,
guidance and constructive criticism for evaluation of this assignment. Special
thanks are due to those friends who help in the completion of the project.
We cannot find words to carbide my deep sense of Gratitude
towards my loving parents. As without their cooperation, inspiration,
encouragement and great patience it would not had been possible to steer the
course of this assignment to fruition.
We thank all of them from the bottom to heart.
PRIYANKA GUPTA
2008/182(008526209589)
RISHI ARORA
2008/187 (008529009692)
SHIVANI ARORA
2008/194(008526209600)

CERTIFICATE

This is to certify that the project titled “ Logic Simplification” is Carried


out by the students:

PRIYANKA GUPTA 2008/182


(008526209589)
RISHI ARORA 2008/187
(008526209592)
SHIVANI ARORA 2008/194
(008526209600)
In partial fulfillment of the requirement for the award of diploma in
COMPUTER ENGG.
From Punjab State Board of Technical Education and Industrial Training.
DATE: ANUPAM GARG
(HOD OF
IT,CSE,ECE)

Table of Contents

 Introduction to Project
• Purpose
• Scope
• Need of project

 Overall description of Project


• Goals of proposed system
• Project requirements
• User characteristics
• Constraints

 Dataflow diagrams
• Level-0 (DFD)

 Functions Used

 Header Files Included

 Coding

 Output screens
• Front Page
• Sub Page having Choice to opt for one
• Using Theorems
• Display various Theorems
• K-map of diff Variables
• Simplified Expression using k-maps

 Conclusion

 Bibliography
Introduction
1.1) PURPOSE

• The software is for the Logic Simplification.


• The software includes:
 Simplify the complex Expression using Various Techniques.
 Express the Simplified Expression Using Basic Logic
Gates..

1.2) SCOPE

• It can be used in Any Digital Labs for such a Computerized


Expression of any complex task and gather whole information
about IC’s Structure.

1.3) NEED OF PROJECT

• Generally we don’t pay attention but it is obvious that much of the


time of ECE Engineer goes into simplifying the Expression and
look into How much min no of Gates are required for such an
Expression ,so , for reducing such time we have just introduce an
attempt to reduce the complexity and Easily find the no of Gates,
In this Project, we have Introduced two methods for solving the
Expression and at last express this simplified Expression using 3
Basic Gates…..
Overall Description

2.1) Goals of proposed system

1. Accuracy: - The level of accuracy in the proposed system will be higher.


All operation would be done correctly and it ensures that whatever
information is coming from the center is accurate.

2. Reliability: - The reliability of the proposed system will be high due to the
above stated reasons. The reason for the increased reliability of the system is
that now there would be proper storage of information.

3. No Redundancy: - In the proposed system utmost care would be that no


information is repeated anywhere, in storage or otherwise. This would assure
economic use of storage space and consistency in the data stored.

4. Immediate retrieval of information: - The main objective of proposed


system is to provide for a quick and efficient retrieval of information. Any
type of information would be available whenever the user requires.

5. Immediate storage of information: - In manual system there are many


problems to store the largest amount of information.

6. Easy to Operate: - The system should be easy to operate and should be


such that it can be developed within a short period of time and fit in the
limited budget of the user having Technical Expertise in ECE..
2.2) Project Requirements

Hardware Requirements
Processor RAM Disk Space

Pentium II, Pentium 64 Mb or Higher 130 Mb


III, Pentium IV or
Higher.
Software Requirements
Operating System Software
WIN-98, WIN-XP, WIN-VISTA Turbo C++
or Any other higher version.

2.3) User Characteristics

Every user should be:


• Comfortable of working with computer.
• He must have knowledge in ELECTRONICS field.
• He must also have basic knowledge of English too.

2.4) Constraints
• GUI is only in English
BASIC LOGIC GATES
Logic is defined as science of reasoning. In other words, it is the
development of a reasonableor logical conclusion based on known
information. A gate is simply an electronic circuit which operates on one or
more input signals to produce an output signal. Logic gates can be
constructed from diodes, transistors and resistors connected in such a way
that circuit output is the result of a basic logic operations performed on the
inputs. The three basic logic gates are:-

 NOT gate or invertor

 AND gate

 OR gate

1.NOT gate or INVERTOR:


The NOT gate or invertor is a gate that accepts one input and produces
one output which is complement of the input given. It performs basic
logic function i.e. complement or inversion. The purpose of NOT gate
is to change one logic level to opposite level i.e. it changes a 1 to 0 and
0 t0 1.

X x`
2.AND gate :
The AND gate is a Logic circuit that requires all the inputs to be high at
same time in order for output to be high. AND gate can have two or
more inputs.If any of the input is low(0),then the output is low(0).
X=A.B;
A X=A.B
B

3.OR gate :
The OR gate is a Logic circuit that requires any of the one inputs to be
high at same time in order for output to be high. OR gate can have two
or more inputs.If any of the input is high(1),then the output is high(1).
X=A+B;

K-MAP:
The Karnaugh Map(k-Map) is a systematic method for simplifying and
manipulating Boolean expression. In this technique information contained in
a truth table in sum of product or product of sum is represented on k-map. It
is used to simplify a logic expression or to convert a truth table to
corresponding ligig circuit in simple orderly process. K-map can be used for
problems involving any no. of input variables but practically limited to six
variables.

VARIOUS HEADER FILES USED &


Functions associated with it:

1)GRAPHICS.H:-
The functions which are refered from graphics. h are
fillellipse, settextstyle, moveto, outtext, closegraph.

SETTEXTSTYLE:-

It sets the text font, the direction in which text is displayed


and size of characters. Its declaration is as:-

void settextstyle(int font, int direction, int char_size);

CLOSEGRAPH:-

It shuts down the graphics system. Its declaration is as:-

void closegraph(void);

SETBKCOLOR:-

It sets the current Background color using palette. It


doesn’t return any value.

Void setbkcolor(int color);

SETTEXTSTYLE:

Sets the current text characterstics.

Settextstyle(int font,int direction,int charsize);

SETCOLOR:-
It sets the current drawing color,which ranges from 0 to
specific color ranges.

Setcolor(color name or color code);

2) CONIO.H:-The functions which are used from this header


file are:-

CLRSCR():-

It clears the current text window and places the cursor in


the upper left hand corner. Its declaration is as:-

void clrscr (void);

GETCH():-

It gets a character from console but does not echo to the


screen. Its declaration is as:-

int getch (void);

GOTOXY():-
It moves the cursor to the given position in the current
text window. Its declaration is as:-

void gotoxy(int x,int y);

where x=column

y=row

3) STDLIB.H:-The functions which are refered from stdlib.h


are:

EXIT:-

Exit terminates execution without closing any files or


calling any exit function.Its declaration is as:-

void exit(int status);

4) IOSTREAM.H:-
This is a file which is mainly used in c++. The functions
which are refered from this file are:-
COUT:-

The cout is used to display an object onto a standard


device. The insertion operator is used along with cout stream.

CIN:-

The cin is used to read a number, a character or a string


of characters from a standard input device, normally
the keyboard. The extraction operator is used along with
the cin operator.

5) STRING.H:- The function which is used from this file is:-

STRCMP:-It compares the two strings and return the


specific value depending upon strings are equal or not. Its
declaration is as:-

Strcmp(str1,str2);

USER –DEFIND FUNCTIONS:-

Istmain()

Scdmain()
Data Flow Diagrams:-

Boolean Expression K-MAP


Simplified Expression
ABOUT
C++
Front end

We have used c++ as front end for our project. C++ was
developed by “Bjarne Stroustrup” of AT&T Bell Laboratories
in the early “1980's”, and is based on the C language. The
name is a pun - "++" is a syntactic construct used in C (to
increment a variable), and C++ is intended as an
incremental improvement of C.
C is in many ways hard to categories. Compared to assembly
language it is high-level,but it never the less. It includes
many low-level facilities to directly manipulate the
computer's memory. It is therefore an excellent language for
writing efficient "systems" programs. But for other types of
programs, C code can be hard to understand, and C
programs can therefore be particularly prone to certain types
of error. The extra object-oriented facilities in C++ are partly
included to overcome these shortcomings.

Concepts of OOP’s

A language calleds OOP’s language. If it supports all the


features of the OOP’s language for understanding OOP’s .First
of all you have to understand few concepts .

1) Object: An Object is a Real Word thing which performs a


specific task and which has a set of Properties and Methods.
Properties of object are also called as attributes of an object
and method is also known as the function of the object like
,what an object can do. For example: A car is an object which
has a certain number of properties like color, model no,
average etc and a function is Known as run.When a user
gives same race then the car will be moved.

2) Class: A Class is that which contains the set of properties


and methods of an object in a single unit . Like Animal is a
name of class which contains all the properties and methods
of an object of another animals. So, if we wants to access any
data from the class then first of all we have to create the
object of a class then ,we can use any data and method from
class.

FIVE CONCEPTS IN OOP’S:

1.DATA ABSTRACTION: Data Abstraction is that in which a


user can use any of the data and method from the class
without knowing about how this is created .So ,in other words
we can say that A user can use all the functions without
knowing about its detail For Example: When a user gives race
to car ,the car will be moved but a user doesn’t know how its
Engine will work

2.INHERITANCE: Inheritance is very popular concept in


OOP’s.This provides the capability to a user to use the
predefined code or the code that is not created by the user
himself but, if he may wants to use that code then he can use
that code. This is called Inheritance but always remember in
Inheritance a user only using the code but he will not be able
to change the code that is previously created he can only use
that code.

3.DATA ENCAPSULATION: Data Encapsulation is also


known as Data hiding. As we know with the inheritance
concept of OPP’s a user can use any code that is previously
created but if a user wants to use that code then it is must
that previously code must be Public. As the name suggests
public means for other peoples but if a code is Private then it
will be known as Encapsulate and user will not be able to use
that code .So ,with the help of OPP’s we can alter or change
the code means we can make the Code as Private or public.
This allows us to make our code either as public or private.

4.POLYMORPHISM : Poly means many and morphism


means many function.The concepts introduces in the form of
many behaviors of an object like an operator + is used for
addition of two numbers and + is also used for joining two
names .The Polymorphism in C++ introduces in the form of
functions overloading and in the form of constructor
overloading .

5.DYNAMIC BINDING: Binding is used when we call the


code of the procedure in binding. All the code that is linked
with the single procedure is called .When a call is made to
that procedure. Then the compiler will found the entire code
of the single procedure. If a compiler will found all the code of
single procedure in compile time then it is called as the early
binding. Because compiler knows about the code at the time
of compilation. But in the Late Binding Compiler will
understand all the code at run time or at the time of the
execution.

“BENEFITS OF OOPS”
OOP’s is used in Several Places The Features of the OOP’s
include----

INHERITANCE: We know that OOP’s provide inheritance


with the help of the inheritance. The code that is previously
code is used in many places where we want.By using the
inheritance. We can create our programs by using pre-
defined code.

C++ is most popular on the Internet. Because after


Compilation the Code of C++ is First Converted into the Byte
code .Then after Interpreter Byte Code is Transfered into the
Machine Code .

“OVERVIEW OF C++”

C++ is general purpose language which is used for


developing Stand alone Programs.

A Simple Example of C++ Program

#include<iostream.h>

Void main()

Cout<<”Have a nice day”;

Void :- Void means the main function will never return a


value or it will simply prints the text on the screen.
cout or output line :- This Line is similar to printf in C for
displaying the results on the screen at the time of
execution .In this ,System is name of package and Out i.e
output is name of class and print is the name of method that
belongs to the output class for displaying the results on the
screen.

“C++ Tokens”
A C++ Program is made up of Classes and Methods. The
Methods are the container of the various statements and a
statement is made up of Variables, Constants, operators
etc .Tokens are the Smallest unit of Program .

• Reserve Word Or Keywords

• Identifier

• Operators

• Separators

• KEYWORDS:- A keyword is that which have a special


meaning those are already been explained to the C++
language like int, float, class, public etc. These are the
reserve keywords .Always remember that we can t give a
name to a variable as the name of a keyword. C++
provides us the many keywords. All the keywords are to
be written into the lower case because C++ is a case
sensitive means Upper case and Lower case. Letters are
Different in C++. Many Keywords are inherit from C.

• IDENTIFIERS :- The identifiers are those which are used


for giving a name to a variable ,class and functions, arrays
,structures etc .

There are some rules against for using the


identifiers.

 Name of identifier not be a keyword.

 Must be start from alphabet not from digit.

 Uppercase and Lowercase are different.

 Identifiers can be of any length.


OPERATOR:- Operators are the special symbols those have
specific functions associated with them for performing the
operations. It needs some operands .

Operands are those on which operations are performed by


the operators.

Like 2 +3 ,

in this + is the Operator and 2 and 3 are the Operands.

SEPARATORS :- These are special symbols used to indicate


the group of code that is either be divided or arrange into the
block. The separators includes parentheses, open curly
braces comma, semicolon, or either it will be period or dot
operator.

“C++ Compiler “
Compiler translates the human code into the byte codes.

“Loops Under C++ “

Computer is used for performing many repetitive types of


tasks .The process of repeatedly performing tasks is known
as looping .The statements in the block may be executed any
number of times from zero to upto the condition is true. The
loop is that in which a task is repeated until the condition is
true or we can say in the loop will executes all the
statements are until the given condition is not to be false.
These are generally used for repeating the statements. In this
there is either entry controlled loop or as exit controlled
loop .We know that before execution of statements all
conditions are checked these are performed by entry
controlled loops.In which it will First checks condition and in
exit controlled loop it checks condition for ending loop
.Whether given condition is false or not if a loop first checks
condition for execution. Then it is called as entry controlled
loop and if a loop checks condition after the execution of
statement then they are called as exit controlled loops.
In the loop generally there are three basic operations are
performed.

1) Initialization

2) Condition check

3) Increment

Three types of loops in the C++

1) while

2) do-while

3) for

All these are used for performing the repetitive tasks until the
given condition is not true.

1) While :- While Loop is Known as Entry Controlled Loop


because in the while loop. We first initialize the value of
variable or start point of execution and then we check the
condition . If the condition is true then, it will execute the
statements and it increments or decrements the value of a
variable. But if the while Condition is false then, it will never
executes the statement

2) Do while:- This is also called as exit controlled loop. We


know, that in the while loop the condition is check before the
execution of the program. But if the condition is not true
then, it will not execute the statements .So, for this purpose
we use do while loop .In this, first it will executes the
statements and then it increments the value of a variable
and then last it checks the condition.So, In this either the
condition is true or not. It execute the statement at least one
time.

3) For: - In this loop all the basic operations like initialization


, condition checking and incrementing or decrementing.All
these are performed in only one line. This is similar to the
while loop for performing its execution but only different in its
syntax.

“Jumping in Loops”

Loop will perfome the execution of statements until the


condition is true .But if we want to executes the statement in
desired order then, we have to use jumping statements.
Jumping Statements are also Called as Control Statements .
The Control or jumping statements are used for controlling
the execution of the program. There are the three control
statements those are break , continue, and labelled loops .

Break This statement is used for stopping the execution of


the program. The break statement is used where we doesn’ t
want to execute the next statement.

Continue The continue statements is used for executing the


statements by skipping a statement for execution. if you don’
t want to execute any statement then we can use the
continue means to skip a particular statement and then
execute the next statements.

Goto: - The goto statement performs an unconditional


transfer of control to the named label. The label must be in
the current function.

“Concept of Classes under C++”


We know that C++ is OOP’s language. In C++ we can also
create classes for reusability of code .All the code must be
reside in classes and if any one wants to use any data or
member functions from class. Then first of all we have to
create object of that class then with the help of dot operator
we can call or use any data member or either member
function from the class. C++ allows all OOP’s concepts like
Data abstraction ,Inheritance, Polymorphism and Data
Encapsulation. All these are achieved only when you will
create code in the form classes .

A Class contains :

1) Data Members or simply called as variables.

2) Member Functions or simply called as functions

“CONSTRUCTOR”

Constructor is that whose name is same as name of variable


and used for initializing the data members of class and it gets
automatically called when an object of class is created .But
always remember some things about constructor like :-

Name of Constructor must be same as name of class.

Have No Return Type Even Not Void.


Automatically Called when an object of class is created .

There are three types of Constructor as follows:-

DEFAULT CONSTRUCTOR:- Default Constructor is also


called as Empty Constructor which has no arguments and it is
automatically called when we creates the object of class but
remember name of constructor is same as name of class .

PARAMETERIZED CONSTRUCTOR: - This is another type of


constructor which has some arguments and same name as
class name but it uses some arguments. So, for this we have
to create object of class by passing some arguments at the
time of creating object with the name of class.

COPY CONSTRUCTOR:- This is also another type of


constructor. In this constructor object of another constructor
is passed as name suggests you .Copy means copy values of
another class object. This is used for copying the values of
class object into an another object of class So ,for calling
copy constructor .We have to pass the name of object whose
values we wants to copying.

C++ has the following characteristics over the other


languages:

 Object-oriented programming
 Portability
 Brevity
 Modular programming
 C Compatibility
 Speed
File Handling
The C++ file system is designed to work with a wide variety
of devices, including terminals, disk drives and tape drives.
Even though each device is very different, the C file system
transforms each into a logical device called a stream. There
are two types of streams text and binary. A Text stream is a
sequence of characters. A binary stream is a sequence of
bytes with a one-to-one correspondence to those in the
external device. It acts either as a source from which the
input data can be obtained or a destination to which the
output data can be sent. The concept is illustrated in the

figure.
Coding
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<graphics.h>
#include<stdlib.h>
class gate
{
int a,b;
public:
int and(int ,int);
int or(int ,int);
int not(int,int);
};

int gate:: and(int x=40,int y=20)


{
int a,b;
setbkcolor(GREEN);
setcolor(1);
line(x,y,x+20,y);
line(x,y+16,x+20,y+16);
line(x+20,y-7,x+45,y-7);
line(x+20,y-7,x+20,y+23);
line(x+20,y+23,x+45,y+23);
arc(x+45,y+8,270,90,15);
line(x+60,y+8,x+80,y+8);
return 0;
}

int gate:: or(int x,int y)


{
setbkcolor(GREEN);
setcolor(1);
line(x,y,x+24,y);
line(x,y+17,x+24,y+17);
line(x+50,y+8,x+70,y+8);
arc(x,y+8,315,45,25);
arc(x,y-42,285,315,70);
arc(x,y+57,44,75,70);
return 0;
}

int gate:: not(int x,int y)


{
setbkcolor(GREEN);
setcolor(1);
line(x+30,y-15,x+30,y+15);
line(x+30,y-15,x+60,y);
line(x+30,y+15,x+60,y);
line(x,y,x+30,y);
circle(x+60,y,1);
circle(x+60,y,2);
line(x+62,y,x+85,y);
return 0;
}
void istmain()
{

setlinestyle(SOLID_LINE,1,3);
setcolor(8);
rectangle(3,3,636,476);
setlinestyle(SOLID_LINE,1,1);
setcolor(4);
rectangle(8,8,631,471);
settextjustify(1,1);
setbkcolor(11);
setcolor(4);
settextstyle(7,0,0);
setusercharsize(17,10,6,3);
outtextxy(320,30,"LOGIC");
outtextxy(360,100,"SIMPLIFICATION");
setusercharsize(2,3,2,3);
settextstyle(1,0,0);
outtextxy(500,220,"Project Submitted By:");
line(360,240,620,240);
outtextxy(500,250,"Priyanka Gupta(182/08)");
outtextxy(500,280,"Rishi Arora(187/08)");
outtextxy(500,310,"Shivani Arora(194/08)");
outtextxy(130,220,"Project Submitted TO:");
line(10,240,250,240);
outtextxy(130,250,"Mrs.Anupam Garg");
outtextxy(130,280,"[ HOD CSE Dept. ]");
outtextxy(130,310,"Lect.Monika Gupta");
outtextxy(130,340,"Lect.Rupinder Kaur");
getch();
clrscr();}
int scdmain()
{
int m;
cleardevice();
setlinestyle(SOLID_LINE,1,1);
rectangle(3,3,636,476);
setlinestyle(SOLID_LINE,1,1);
rectangle(8,8,631,471);
settextjustify(1,1);
textcolor(15);
setbkcolor(15);
setcolor(6);
settextstyle(7,0,0);
setusercharsize(2,3,2,3);
outtextxy(320,80,"The Two Proposed Way To Simplify");
outtextxy(360,110,"The Boolean Expression:");
setusercharsize(2,3,2,3);
settextstyle(1,0,0);
outtextxy(350,200,"\n\t\t1. The Various Theorams.....");
outtextxy(385,250,"2. Through Karnaugh Map(k-map)");
outtextxy(280,380,"Enter The Choice(1/2):");
cin>>m;
char s[4];
itoa(m,s,10);
outtextxy(440,380,s);
getch();
clrscr();
return(m);
}

void main()
{
gate g;
int gd,gm,m;
gd=DETECT;
int h,n;
initgraph(&gd,&gm,"d:\\software\\tur-cpp\\bgi");
cleardevice();
istmain();
m=scdmain();
if(m==1)
{
cleardevice();
setbkcolor(GREEN);
textcolor(GREEN);
setcolor(BLUE);
clrscr();
settextstyle(0,0,1);
cout<<"\n\n\t\tTHE VARIOUS LAWS FOR LOGIC SIMPLIFICATION:";
cout<<"\n\n\n\t\tCHOOSE ANY OF THE FOLLOWING LAW TO IMPLEMENT";
cout<<"\n\n\t\t\t(a)INDEMPOTENT LAW";
cout<<"\n\n\t\t\t(b)COMPLEMENTRY LAW";
cout<<"\n\n\t\t\t(c)INVOLUTION LAW";
cout<<"\n\n\t\t\t(d)COMMUTATIVE LAW";
cout<<"\n\n\t\t\t(e)ASSOCIATIVE LAW";
cout<<"\n\n\t\t\t(f)DISTRIBUTIVE LAW";
cout<<"\n\n\t\t\t(g)ABSORPTION LAW";
cout<<"\n\n\t\t\t(h)ALGEBRIC RULE";
cout<<"\n\n\t\t\t(i)DEMORGANS THEORMS:";
cout<<"\n\n\t\t\t(x)FOR EXIT";
char ch;
cout<<"\n\t\tEnter choice:";
cin>>ch;
switch(ch)
{
case'a': //For Implementing Indempotent Law
{
clrscr();
cout<<"\nThe Indempotent Law States that:";
cout<<"\n\n\t1. If a variable is ORed with itself then output is equal to variable itself.";
cout<<"\n\n\t\t\t\t\t\tX+X=X";
cout<<"\n\n\t2. If a variable is ANDed with itself then output is equal to variable itself." ;
cout<<"\n\n\n\t\t\t\t\t\tX.X=X";
cout<<"\n\nEnter Choice(1/2):";
int p;
cin>>p;
if(p==1)
{
clrscr();
int i;
cout<<"\nEnter Value (1/0)of x=";
cin>>i;
int result;
char s[4];
result=(i | i);
g.or(100,100);
itoa(i,s,10);
outtextxy(100,90,s);
outtextxy(100,125,s);
itoa(result,s,10);
outtextxy(175,107,s);
}
else if(p==2)
{
clrscr();
int i;
cout<<"\nEnter Value (1/0)of x=";
cin>>i;
int result;
char s[4];
result=(i & i);
g.and(100,100);
itoa(i,s,10);
outtextxy(100,90,s);
outtextxy(100,125,s);
itoa(result,s,10);
outtextxy(182,103,s);
}
break;
}
case'b': // For Implementing Complementary Law
{
clrscr();
cout<<"\n\n\tTHIS LAW STATES:";
cout<<"\n\n\t1.If a variable and its complement are ORed,result is always 1:";
cout<<"\n\n\t\t\tX+X'=1";
cout<<"\n\n\t2.If a variable and its complement are ANDed,result is always 0:";
cout<<"\n\n\t\t\tX.X'=0";
int i,com,result,p;
char s[4];
cout<<"\n\n\t\tEnter The Choice(1/2)";
cin>>p;
getch();
clrscr();
if(p==1)
{
cout<<"\n\t\tEnter Input(1/0):";
cin>>i;
if(i==1)
{
com=0;
}
if(i==0)
{
com=1;
}
result=(i | com);
g.or(100,100);
itoa(i,s,10);
outtextxy(100,90,s);
itoa(com,s,10);
outtextxy(100,125,s);
itoa(result,s,10);
outtextxy(175,107,s);
}
if(p==2)
{
cout<<"\n\t\tEnter Input(1/0):";
cin>>i;
if(i==1)
{
com=0;
}
if(i==0)
{
com=1;
}
result=(i & com);
g.and(100,100);
itoa(i,s,10);
outtextxy(100,90,s);
itoa(com,s,10);
outtextxy(100,125,s);
itoa(result,s,10);
outtextxy(183,102,s);
}
break;
}

case'c': // For Implementing Involution Law


{
clrscr();
cout<<"\n\n\nTHIS LAW STATES THAT:";
cout<<"\n\n\tIf a variable is complemented twice,the result is variable itself i.e.";
cout<<"\n\t\t\t\t\tX''=X";
int i,com;
char s[4];
getch();
clrscr();
cout<<"\n\n\t\tEnter Input(1/0):";
cin>>i;
g.not(100,100);
itoa(i,s,10);
outtextxy(92,95,s);
if(i==1)
{
com=0;
}
if(i==0)
{
com=1;
}
itoa(com,s,10);
outtextxy(190,90,s);
g.not(180,100);
if(com==1)
com=0;
else
com=1;
itoa(com,s,10);
outtextxy(267,94,s);
break;
}

case'd': // For Implementing Commulative Law


{
clrscr();
cout<<"\n\n\tTHIS LAW STATES:";
cout<<"\n\n\t1.The order in which variables are ORed makes no difference i.e.";
cout<<"\n\n\t\t\tX+Y=Y+X";
cout<<"\n\n\t2.The order in which variables are ANDed makes no difference i.e.";
cout<<"\n\n\t\t\tX.Y=Y.X";
getch();
clrscr();
rectangle(100,65,350,215);
line(100,90,350,90);
outtextxy(105,81,"X");
outtextxy(155,81,"Y");
line(175,65,175,215);
line(262,65,262,215);
outtextxy(210,81,"X+Y");
outtextxy(300,81,"Y+X");
char s[4];
int i=0;
itoa(i,s,10);
outtextxy(105,115,s);
outtextxy(105,145,s);
i=1;
itoa(i,s,10);
outtextxy(105,175,s);
outtextxy(105,205,s);
outtextxy(150,145,s);
outtextxy(150,205,s);
i=0;
itoa(i,s,10);
outtextxy(150,115,s);
outtextxy(150,175,s);
outtextxy(220,115,s);
i=1;
itoa(i,s,10);
outtextxy(220,145,s);
outtextxy(220,175,s);
outtextxy(220,205,s);
outtextxy(300,115,s);
outtextxy(300,145,s);
outtextxy(300,175,s);
i=0;
itoa(i,s,10);
outtextxy(300,205,s);
clrscr();
cout<<"\nEnter The Inputs:";
int in,jn,result;
cin>>in>>jn;
result=(in|jn);
g.or(100,100);
itoa(in,s,10);
outtextxy(100,90,s);
itoa(jn,s,10);
outtextxy(100,125,s);
itoa(result,s,10);
outtextxy(175,107,s);
outtextxy(300,107,"=");
result=(jn|in);
g.or(350,100);
itoa(jn,s,10);
outtextxy(350,90,s);
itoa(in,s,10);
outtextxy(350,125,s);
itoa(result,s,10);
outtextxy(425,107,s);
break;
}

case'e': // For Implementing Associative Law


{
int p;
clrscr();
cout<<"\n\n\t\tTHIS LAW STATES:";
cout<<"\n\n\n1.When you are ORing several variables,the result is same regardless of grouping of
variables:";
cout<<"\n\n\t\tX+(Y+Z)=(X+Y)+Z";
cout<<"\n\n\n2.When you are ANDing several variables,the result is same regardless of grouping of
variables:";
cout<<"\n\n\t\tX(YZ)=(XY)Z";
cout<<"\n\n\t\tEnter The Choice(1/2):";
cin>>p;
clrscr();
cout<<"\nEnter The Three Inputs:" ;
int in,jn,kn,result;
char s[4];
cin>>in>>jn>>kn;
if(p==1)
{
result=(in|jn);
itoa(in,s,10);
outtextxy(100,90,s);
itoa(kn,s,10);
outtextxy(100,140,s);
itoa(result,s,10);
outtextxy(175,101,s);
line(170,107,170,119);
line(170,150,170,138);
g.or(100,100);
g.or(170,119);
result=(result|kn);
itoa(result,s,10);
outtextxy(245,125,s);
itoa(jn,s,10);
outtextxy(100,107,s);
line(100,150,170,150);
outtextxy(265,128,"=");
result=(jn|kn);
line(285,100,355,100);
itoa(in,s,10);
outtextxy(290,90,s);
itoa(jn,s,10);
outtextxy(284,120,s);
line(355,100,355,112);
line(355,138,355,128);
result=(result|kn);
itoa(result,s,10);
outtextxy(430,118,s);
g.or(285,130);
g.or(355,112);
itoa(kn,s,10);
outtextxy(285,138,s);
}
if(p==2)
{
result=(in&jn);
itoa(in,s,10);
outtextxy(100,90,s);
itoa(kn,s,10);
outtextxy(100,140,s);
itoa(result,s,10);
outtextxy(180,101,s);
line(175,107,175,119);
line(175,150,175,135);
g.and(95,100);
g.and(175,119);
result=(result&kn);
itoa(result,s,10);
outtextxy(250,118,s);
itoa(jn,s,10);
outtextxy(100,107,s);
line(100,150,175,150);
outtextxy(265,128,"=");
result=(jn&kn);
line(285,100,365,100);
itoa(in,s,10);
outtextxy(290,90,s);
itoa(jn,s,10);
outtextxy(284,120,s);
line(365,100,365,113);
line(365,138,365,128);
result=(result|kn);
itoa(result,s,10);
outtextxy(440,112,s);
g.and(285,130);
g.and(365,112);
itoa(kn,s,10);
outtextxy(285,138,s);
}
break;
}

case'f': // For Implementing Distributive Law


{
clrscr();
cout<<"\n\n\n\t\tTHIS LAW STATES:";
cout<<"\n\n\t\t1.This law states that ORing several variables and ANDing the result with single variable
is equivalent to ANDing the single variable with each of the several variables and then ORing the products.This law can
be used for expanding an equation containing OR and AND gates.";
cout<<"\n\n\t\tX(Y+Z)=XY+YZ";
g.or(125,300);
line(125,260,195,260);
line(195,260,195,275);
line(195,307,195,291);
g.and(195,275);
outtextxy(295,282,"=");
outtextxy(125,250,"X");
outtextxy(125,290,"Y");
outtextxy(125,320,"Z");
g.and(315,260);
outtextxy(305,250,"X");
outtextxy(305,270,"Y");
line(320,260,320,310);
g.and(315,310);
outtextxy(305,320,"Z");
line(395,267,395,280);
outtextxy(407,270,"XY");
outtextxy(405,304,"XZ");
outtextxy(474,285,"XY+XZ");
line(395,319,395,296);
g.or(395,280);
cout<<"\n\n\t\tThe Other Law States That:";
cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\tX+YZ=(X+Y)(X+Z)";
cout<<"\n\n\n\t\t\tTo see the proof press any key:";
getch();
clrscr();
cout<<"\n\n\t\tX+(Y+Z)=XY+XZ";
rectangle(65,80,580,300);
line(115,80,115,300);
line(165,80,165,300);
line(215,80,215,300);
line(280,80,280,300);
line(360,80,360,300);
line(420,80,420,300);
line(500,80,500,300);
line(580,80,580,300);
line(65,110,580,110);
outtextxy(85,90,"X");
outtextxy(135,90,"Y");
outtextxy(185,90,"Z");
outtextxy(245,90,"Y+Z");
outtextxy(305,90,"XY");
outtextxy(380,90,"XZ");
outtextxy(445,90,"X(Y+Z)");
outtextxy(525,90,"XY+XZ");
char s[4];
int in,jn,kn,result;
in=0;
itoa(in,s,10);
outtextxy(85,115,s);
outtextxy(85,140,s);
outtextxy(85,165,s);
outtextxy(85,190,s);
outtextxy(135,115,s);
outtextxy(135,140,s);
outtextxy(185,115,s);
outtextxy(245,115,s);
outtextxy(315,115,s);
outtextxy(385,115,s);
outtextxy(455,115,s);
outtextxy(535,115,s);
outtextxy(535,140,s);
outtextxy(535,165,s);
outtextxy(535,190,s);
outtextxy(455,140,s);
outtextxy(455,215,s);
outtextxy(455,165,s);
outtextxy(455,190,s);
outtextxy(385,140,s);
outtextxy(385,165,s);
outtextxy(385,190,s);
outtextxy(385,215,s);
outtextxy(315,140,s);
outtextxy(315,165,s);
outtextxy(315,190,s);
outtextxy(315,215,s);
outtextxy(315,240,s);
outtextxy(245,215,s);
outtextxy(185,165,s);
outtextxy(185,215,s);
outtextxy(185,265,s);
outtextxy(135,215,s);
outtextxy(135,240,s);
outtextxy(385,265,s);
outtextxy(535,215,s);
in=1;
itoa(in,s,10);
outtextxy(85,215,s);
outtextxy(85,240,s);
outtextxy(85,265,s);
outtextxy(85,290,s);
outtextxy(135,165,s);
outtextxy(135,190,s);
outtextxy(135,265,s);
outtextxy(135,290,s);
outtextxy(185,140,s);
outtextxy(185,190,s);
outtextxy(185,240,s);
outtextxy(185,290,s);
outtextxy(245,140,s);
outtextxy(245,165,s);
outtextxy(245,190,s);
outtextxy(245,240,s);
outtextxy(245,265,s);
outtextxy(245,290,s);
outtextxy(385,290,s);
outtextxy(385,240,s);
outtextxy(315,265,s);
outtextxy(315,290,s);
outtextxy(455,290,s);
outtextxy(455,265,s);
outtextxy(455,240,s);
outtextxy(535,240,s);
outtextxy(535,265,s);
outtextxy(535,290,s);
getch();
clrscr();
cout<<"\n\n\nEnter The Three Inputs:";
cin>>in>>jn>>kn;
g.and(115,300);
line(125,260,195,260);
line(195,260,195,275);
line(195,308,195,293);
g.or(195,275);
outtextxy(295,282,"=");
itoa(in,s,10);
outtextxy(125,250,s);
itoa(jn,s,10);
outtextxy(125,290,s);
itoa(kn,s,10);
outtextxy(125,320,s);
g.or(325,260);
itoa(in,s,10);
outtextxy(310,255,s);
itoa(jn,s,10);
outtextxy(310,275,s);
line(330,260,330,310);
g.or(325,310);
itoa(kn,s,10);
outtextxy(305,320,s);
result=(jn&kn);
itoa(result,s,10);
outtextxy(202,284,s);
result=(result|in);
itoa(result,s,10);
outtextxy(245,267,s);
line(395,267,395,282);
result=(in|jn);
itoa(result,s,10);
outtextxy(400,270,s);
itoa(kn,s,10);
outtextxy(397,304,s);
result=(result&kn);
outtextxy(465,293,s);
line(395,317,395,300);
g.and(395,282);
break;
}

case'g': //For Implementing Absorption Law


{
clrscr();
cout<<"\n\n\t\tTHIS LAW STATES THAT:";
cout<<"\n\n\n\t\t\tX+XY=X";
int in,jn,result;
char s[4];
line(100,100,210,100);
outtextxy(90,95,"X");
line(130,100,130,150);
g.and(130,150);
outtextxy(130,172,"Y");
outtextxy(197,162,"XY");
line(210,100,210,118);
line(210,157,210,135);
g.or(210,118);
outtextxy(217,108,"X");
outtextxy(270,116,"X+XY");
cout<<"\n\n\n\n\n\n\n\t\t\tTHE OTHER LAW STATES :";
cout<<"\n\n\t\tX(X+Y)=X";
line(100,270,200,270);
line(200,270,200,290);
g.and(200,290);
outtextxy(90,260,"X");
line(130,270,130,320);
g.or(130,320);
outtextxy(120,335,"Y");
outtextxy(177,333,"X+Y");
line(200,327,200,307);
g.and(130,150);
outtextxy(267,285,"X(X+Y)");
outtextxy(130,172,"Y");
outtextxy(197,162,"XY");
line(210,100,210,118);
line(210,157,210,135);
g.or(210,118);
outtextxy(217,108,"X");
outtextxy(270,116,"X+XY");
getch();
clrscr();
int p;
cout<<"\n\t\tEXAMPLE:" ;
cout<<"\n\t\tEnter choice(1/2):";
cin>>p;
cout<<"\n\t\tEnter the inputs:";
cin>>in>>jn;
if(p==1)
{
result=(in & jn) ;
line(100,100,210,100);
itoa(in,s,10);
outtextxy(90,95,s);
line(130,100,130,150);
g.and(130,150);
itoa(jn,s,10);
outtextxy(130,172,s);
itoa(result,s,10);
outtextxy(197,162,s);
line(210,100,210,118);
line(210,157,210,135);
g.or(210,118);
result=(result|in);
outtextxy(270,116,s);
}
if(p==2)
{
line(100,270,200,270);
line(200,270,200,290);
g.and(200,290);
itoa(in,s,10);
outtextxy(90,260,s);
line(130,270,130,320);
g.or(130,320);
itoa(jn,s,10);
result=in|jn;
itoa(result,s,10);
outtextxy(120,335,s);
outtextxy(177,333,s);
line(200,327,200,307);
result=(result&in);
itoa(result,s,10);
outtextxy(267,285,s);
}
break;
}

case'h': // FOR Implementing Algebric Rules


{
clrscr();
cout<<"\n\n\t\tTHIS LAW STATES :";
cout<<"\n\n\n\n\t\t1.X+X'Y=X+Y";
cout<<"\n\n\n\n\t\t2.XY+YZ+Y'Z=XY+Z";
cout<<"\n\n\tTo see example press any key:" ;
getch();
clrscr();
cout<<"\n\n\t\tEXAMPLE:";
cout<<"\n\n\t\tEnter Two Inputs:";
int in,jn,result,com;
cin>>in>>jn;
if(in==1)
com=0;
if(in==0)
com=1;
result=(com&jn);
line(100,100,273,100);
line(120,100,120,150);
g.not(120,150);
g.and(195,150);
line(273,159,273,138);
line(273,100,273,119);
g.or(273,119);
char s[4];
itoa(in,s,10);
outtextxy(90,95,s);
itoa(com,s,10);
outtextxy(195,140,s);
itoa(jn,s,10);
outtextxy(185,157,s);
itoa(result,s,10);
outtextxy(264,150,s);
result=(result|jn);
itoa(result,s,10);
outtextxy(345,125,s);
outtextxy(365,125,"=");
g.or(385,125);
itoa(in,s,10);
outtextxy(375,120,s);
itoa(jn,s,10);
outtextxy(375,137,s);
result=(in|jn);
itoa(result,s,10);
outtextxy(457,129,s);
break;
}

case'i': // For Implementing De-Morgans Theorem


{
clrscr();
cout<<"THE TWO THEOREMS ARE:";
cout<<"\n\n\n\t\t\t* (XY)'=X'+Y'";
cout<<"\n\n\n\t\t\t* (X+Y)'=X'.Y'";
cout<<"\n\n\t\tEnter 1 for theorem 1 and 2 for theorem 2";
int p,in,jn,result,com,comi,comj;
char s[4];
cin>>p;
if(p==1)
{
clrscr();
cout<<"\n\n\t\tEnter the Two Inputs:";
cin>>in>>jn;
g.and(150,150);
g.not(225,158);
itoa(in,s,10);
outtextxy(140,140,s);
itoa(jn,s,10);
outtextxy(140,160,s);
result=in&jn;
itoa(result,s,10);
outtextxy(220,147,s);
if(result==1)
com=0;
if(result==0)
com=1;
itoa(com,s,10);
outtextxy(300,150,s);
outtextxy(330,155,"=");
g.not(350,150);
g.not(350,195);
itoa(in,s,10);
outtextxy(340,140,s);
itoa(jn,s,10);
outtextxy(340,195,s);
line(435,150,435,165);
line(435,195,435,180);
g.or(435,165);
if(in==1)
comi=0;
if(in==0)
comi=1;
itoa(comi,s,10);
outtextxy(420,140,s);
if(jn==1)
comj=0;
if(jn==0)
com=1;
itoa(comj,s,10);
outtextxy(420,185,s);
result=comi|comj;
itoa(result,s,10);
outtextxy(505,160,s);
}
if(p==2)
{
clrscr();
cout<<"\n\n\t\tEnter the Two Inputs:";
cin>>in>>jn;
g.or(150,150);
g.not(215,158);
itoa(in,s,10);
outtextxy(140,140,s);
itoa(jn,s,10);
outtextxy(140,160,s);
result=in|jn;
itoa(result,s,10);
outtextxy(220,147,s);
if(result==1)
com=0;
if(result==0)
com=1;
itoa(com,s,10);
outtextxy(300,150,s);
outtextxy(330,155,"=");
g.not(350,150);
g.not(350,195);
itoa(in,s,10);
outtextxy(340,140,s);
itoa(jn,s,10);
outtextxy(340,195,s);
line(435,150,435,165);
line(435,195,435,180);
g.and(435,165);
if(in==1)
comi=0;
if(in==0)
comi=1;
itoa(comi,s,10);
outtextxy(420,140,s);
if(jn==1)
comj=0;
if(jn==0)
com=1;
itoa(comj,s,10);
outtextxy(420,185,s);
result=comi&comj;
itoa(result,s,10);
outtextxy(505,160,s);
}
break;
}

case'x':
exit(0);
break;
default: // For Any Wrong input
{
clrscr();
cout<<"\n\n\n\n\n\n\n\n\t\t\tEnter valid choice...............";
}
}
getch();
}
else if(m==2) //For Displaying the K-Map
{
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
setbkcolor(8);
textcolor(8);
rectangle(3,3,636,476);
setlinestyle(SOLID_LINE,1,1);
clrscr();
rectangle(8,8,631,471);
settextjustify(1,1);
setcolor(15);
settextstyle(5,0,0);
setusercharsize(4,4,2,3);
outtextxy(320,80,"The Simplified Expression Using K-MAP");
outtextxy(360,120,"&& Expressed Using Logic Gates::::::");
settextstyle(1,0,0);
setusercharsize(2,4,2,3);
outtextxy(400,270,"For Ex:");
rectangle(400,300,500,400);
line(450,300,450,400);
line(400,350,500,350);
outtextxy(430,320,"1");
outtextxy(480,370,"1");
getch();
clrscr();
cout<<"\n\tEnter the no.of variables in the expression f():{ <= 3 }";
cin>>n;
cout<<"\n\n\tHow many Boxes:";
cin>>h;
cout<<"\n\n\tEnter the Boxes:";
int a[16],c[10],count=0;
for(int i=0;i<8;i++)
{
c[i]=0;
}
for(i=0;i<h;i++)
{

cin>>a[i];
}

switch(n)
{
case 2: //For two variables Expression
{
int b[2][2];
rectangle(150,175,210,225);
line(180,150,180,225);
line(120,200,210,200);
settextstyle(0,0,1);
outtextxy(160,150,"A`");
outtextxy(120,180,"B`");
outtextxy(120,210,"B");
outtextxy(160,160,"0");
outtextxy(190,150,"A");
outtextxy(190,160,"1");
outtextxy(135,180,"0");
outtextxy(135,210,"1");
for(i=0;i<h;i++)
{ // For displaying the K-Map
switch(a[i])
{
case 0:
outtextxy(160,183,"1");
b[0][0]=1;
break;
case 1:
outtextxy(190,183,"1");
b[0][1]=1;
break;
case 2:
outtextxy(160,210,"1");
b[1][0]=1;
break;
case 3:
outtextxy(190,210,"1");
b[1][1]=1;
break;

}
}
getch();
closegraph();
if(h==2)
{
if (b[0][0]==1&&b[1][1]==1)
cout<<"\nExpression is:"<<"A'B'+AB";
}

if(h==2)
{
if(b[0][1]==1&&b[1][0]==1)
cout<<"\nExpression is:"<<"AB'+A'B";
}
if(b[0][0]==1 && b[0][1]==1 && b[1][0]==1 && b[1][1]==1) // For resulting in the simplified
Expression Form
{
cout<<"\nExpression is : 0";
getch();
}
else
{
if(b[0][0]==1 && b[0][1]==1)
{
if(b[1][1]==1)
cout<<"\n Expression is:"<<"A+B'";
else if(b[1][0]==1)
cout<<"\n Expression is:"<<"A`+B";
else
cout<<"\n Expression is:"<<"B`";
}
else if(b[0][0]==1 && b[1][0]==1)
{
if (b[1][1]==1)
cout<<"\n Expression is:"<<"A`+B";
else if(b[0][1]==1)
cout<<"\ne\Expression is"<<"A'+B'";
else
cout<<"\n Expression is:"<<"A`";
}
else if(b[1][0]==1 && b[1][1]==1)
{
if(b[0][1]==1)
cout<<"\n Expression is:"<<"A+B";
else if(b[0][0]==1)
cout<<"\nExpression is:"<<"A'+B";
else
cout<<"\n Expression is:"<<"B";
}
else if(b[0][1]==1 && b[1][1]==1)
cout<<"\n Expression is:"<<"A";
getch();
break;

}
}
case 3: // For Expression having 3 variables
{
rectangle(100,175,220,225);
line(130,150,130,225);
line(160,150,160,225);
line(190,150,190,225);
line(220,150,220,225);
line(75,200,220,200);
outtextxy(100,155,"A`B`");
outtextxy(100,165,"0");
outtextxy(115,165,"0");
outtextxy(133,155,"A`B");
outtextxy(133,165,"0");
outtextxy(148,165,"1");
outtextxy(163,155,"A");
outtextxy(178,155,"B");
outtextxy(163,165,"1");
outtextxy(178,165,"1");
outtextxy(193,155,"A");
outtextxy(205,155,"B`");
outtextxy(193,165,"1");
outtextxy(205,165,"0");
outtextxy(77,177,"C`");
outtextxy(77,190,"0");
outtextxy(77,203,"C");
outtextxy(77,218,"1");
int hflag=0,qh1=0,qh2=0,qh3=0;
int trv[2][4]={0,0,0,0,0,0,0,0};
int ctrv[2][4];
for(i=0;i<h;i++) // For display the K-Map
{
switch(a[i])
{
case 0:
outtextxy(115,185,"1");
trv[0][0]=1;
break;
case 1:
outtextxy(145,185,"1");
trv[0][1]=1;
break;
case 2:

outtextxy(175,185,"1");
trv[0][2]=1;
break;
case 3:
outtextxy(205,185,"1");
trv[0][3]=1;
break;
case 4:
outtextxy(115,205,"1");
trv[1][0]=1;
break;
case 5:
outtextxy(145,205,"1");
trv[1][1]=1;
break;
case 6:

outtextxy(205,205,"1");
trv[1][3]=1;
break;
case 7:
outtextxy(175,205,"1");
trv[1][2]=1;
break;
}
}
for(int e=0;e<=1;e++)
{
for(int t=0;t<=3;t++)
{
ctrv[e][t]=trv[e][t];
}
}
getch();
fflush(stdout);
flushall(); // For display the simplified Expression
for(i=0;i<=3;i++)
{
if(trv[0][i]==1)
{
qh1=1;

}
else
{
qh1=0;
break;
}
}
fflush(stdout);
fflush(stdin);
for(i=0;i<=3;i++)
{

if(trv[1][i]==1)
{
qh2=1;
}
else
{
qh2=0;
break;
}
}

if(qh2==1 && qh1==0)


{

if(count==0)
{
clrscr();
cout<<"\n\n\t\tExpression is: C";
}
else
{
cout<<"+C";
}
count++;
for(i=0;i<=3;i++)
{
ctrv[1][i]=0;
}
}

else if(qh2==0 && qh1==1)


{

if(count==0)
{
clrscr();
cout<<"C'";
}
else
{
cout<<"+C'";
}
count++;
for(i=0;i<=3;i++)
{
ctrv[0][i]=0;
}
}

else if(qh2==1 && qh1==1)


{
cleardevice();
clrscr();
cout<<"\n\n\n\t\t\tExPreSSion is: 0 ";
getch();
exit(0);
}
else if(ctrv[0][0]==1)
{
if((trv[0][3]==1) &&(trv[1][0]==1)&&(trv[1][3]==1))
{
if(count==0)
{
clrscr();
cout<<"B'";
}
else
{
cout<<"+B'";
}
count++;
ctrv[0][0]=0;
ctrv[0][3]=0;
ctrv[1][0]=0;
ctrv[1][3]=0;

}
}
for(int j=0;j<=2;j++)
{
if(ctrv[0][j]==1)
{
if((trv[0][j+1]==1)&&(trv[1][j]==1)&&(trv[1][j+1]==1))
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"A'";
}
else
{
cout<<"+A'";
}
count++;
ctrv[0][0]=0;
ctrv[0][1]=0;
ctrv[1][0]=0;
ctrv[1][1]=0;

break;

case 1:

if(count==0)
{
clrscr();
cout<<"B";
}
else
{
cout<<"+B";
}
count++;
ctrv[0][1]=0;
ctrv[0][2]=0;
ctrv[1][1]=0;
ctrv[1][2]=0;

break;
case 2:

if(count==0)
{
clrscr();
cout<<"A";
}
else
{
cout<<"+A";
}
count++;
ctrv[0][2]=0;
ctrv[0][3]=0;
ctrv[1][2]=0;
ctrv[1][3]=0;
break;
}
}

}
}
for(j=0;j<=2;j++)
{
if(ctrv[1][j]==1)
{
if((trv[1][j+1]==1)&&(trv[0][j]==1)&&(trv[0][j+1]==1))
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"A'";
}
else
{
cout<<"+A'";
}
count++;
ctrv[0][0]=0;
ctrv[0][1]=0;
ctrv[1][0]=0;
ctrv[1][1]=0;

break;
case 1:

if(count==0)
{
clrscr();
cout<<"B";
}
else
{
cout<<"+B";
}
count++;
ctrv[0][1]=0;
ctrv[0][2]=0;
ctrv[1][1]=0;
ctrv[1][2]=0;

break;
case 2:

if(count==0)
{
clrscr();
cout<<"A";
}
else
{
cout<<"+A";
}
count++;
ctrv[0][2]=0;
ctrv[0][3]=0;
ctrv[1][2]=0;
ctrv[1][3]=0;
break;
}
}

}
}

if(ctrv[0][0]==1)
{
if(trv[0][3]==1)
{
if(count==0)
{
clrscr();
cout<<"b'c'";
}
else
{
cout<<"+b'c'";
}

count++;
ctrv[0][0]=0;
ctrv[0][3]=0;
}
}
if(ctrv[1][0]==1)
{
if(trv[1][3]==1)
{
if(count==0)
{
clrscr();
cout<<"b'c";
}
else
{
cout<<"+b'c";
}
count++;
ctrv[1][0]=0;
ctrv[1][3]=0;
}
}
for(j=0;j<=2;j++)
{
if(ctrv[0][j]==1)
{
if(trv[0][j+1]==1)
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"a'c'";
}
else
{
cout<<"+a'c'";
}
count++;
ctrv[0][0]=0;
ctrv[0][1]=0;

break;
case 1:

if(count==0)
{
clrscr();
cout<<"bc'";
}
else
{
cout<<"+bc'";
}
count++;
ctrv[0][1]=0;
ctrv[0][2]=0;

break;
case 2:

if(count==0)
{
clrscr();
cout<<"ac'";
}
else
{
cout<<"+ac'";
}
count++;
ctrv[0][2]=0;
ctrv[0][3]=0;
break;
}
}

else if(trv[1][j]==1)
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"a'b'";
}
else
{
cout<<"+a'b'";
}
count++;
ctrv[0][0]=0;
ctrv[1][0]=0;

break;
case 1:

if(count==0)
{
clrscr();
cout<<"a'b";
}
else
{
cout<<"+a'b";
}
count++;
ctrv[0][1]=0;
ctrv[1][1]=0;

break;
case 2:

if(count==0)
{
clrscr();
cout<<"ab";
}
else
{
cout<<"+ab";
}
count++;
ctrv[0][2]=0;
ctrv[1][2]=0;
break;
}
}
}
}
if(ctrv[0][3]==1)
{
if(trv[1][3]==1)
{
if(count==0)
{
clrscr();
cout<<"ab'";
}
else
{
cout<<"+ab'";
}
count++;
ctrv[0][3]=0;
ctrv[1][3]=0;
} }
for(j=0;j<=2;j++)
{
if(ctrv[1][j]==1)
{
if(trv[1][j+1]==1)
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"a'c";
}
else
{
cout<<"+a'c";
}
count++;
ctrv[1][0]=0;
ctrv[1][1]=0;
break;
case 1:

if(count==0)
{
clrscr();
cout<<"bc";
}
else
{
cout<<"+bc";
}
count++;
ctrv[1][1]=0;
ctrv[1][2]=0;

break;
case 2:

if(count==0)
{
clrscr();
cout<<"ac";
}
else
{
cout<<"+ac";
}
count++;
ctrv[1][2]=0;
ctrv[1][3]=0;
break;
}
}

else if(trv[0][j]==1)
{
switch(j)
{
case 0:
if(count==0)
{
clrscr();
cout<<"a'b'";
}
else
{
cout<<"+a'b'";
}
count++;
ctrv[0][0]=0;
ctrv[1][0]=0;

break;
case 1:

if(count==0)
{
clrscr();
cout<<"a'b";
}
else
{
cout<<"+a'b";
}
count++;
ctrv[0][1]=0;
ctrv[1][1]=0;

break;
case 2:

if(count==0)
{
clrscr();
cout<<"ab";
}
else
{
cout<<"+ab";
}
count++;
ctrv[0][2]=0;
ctrv[1][2]=0;
break;
}
}
}
}

if(ctrv[1][3]==1)
{
if(trv[0][3]==1)
{
if(count==0)
{
clrscr();
cout<<"ab'";
}
else
{
cout<<"+ab'";
}
count++;
ctrv[0][3]=0;
ctrv[1][3]=0;
}
}

for(j=0;j<=3;j++)
{
if(ctrv[0][j]==1)
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"a'b'c'";
}
else
{
cout<<"+a'b'c'";
}
count++;
ctrv[0][0]=0;
break;
case 1:

if(count==0)
{
clrscr();
cout<<"a'bc'";
}
else
{
cout<<"+a'bc'";
}
count++;
ctrv[0][1]=0;
break;
case 2:

if(count==0)
{
clrscr();
cout<<"abc'";
}
else
{
cout<<"+abc'";
}
count++;
ctrv[0][2]=0;
break;
case 3:

if(count==0)
{
clrscr();
cout<<"ab'c'";
}
else
{
cout<<"+ab'c'";
}
count++;
ctrv[0][3]=0;
break;
}
}
if(ctrv[1][j]==1)
{
switch(j)
{
case 0:

if(count==0)
{
clrscr();
cout<<"a'b'c";
}
else
{
cout<<"+a'b'c";
}
count++;
ctrv[1][0]=0;
break;
case 1:

if(count==0)
{
clrscr();
cout<<"a'bc";
}
else
{
cout<<"+a'bc";
}
count++;
ctrv[1][1]=0;
break;
case 2:
if(count==0)
{
clrscr();
cout<<"abc";
}
else
{
cout<<"+abc";
}
count++;
ctrv[1][2]=0;
break;
case 3:

if(count==0)
{
clrscr();
cout<<"ab'c";
}
else
{
cout<<"+ab'c";
}
count++;
ctrv[1][3]=0;
break;
}
} }
}
getch();
}
}
else
{
clrscr();
cout<<"\n\n\n\t\tOoops!!!!! Enter Between 2 Valid Choices(1/2):" ;
}
getch();
}

OUTPUT
SCREENS
1. Welcome Page:

2.Choice Page:
3.Various Laws:

4.Explanation of Law:
5.Law using Logic Gates

6.Distributive Law:
7.Truth Table(T-T) of Distributive Law:

8.Displaying Distributive Law:


9.K-Map Evaluation:
10.K-Map Using 2 Variables:

11.Simplified Expression of input:

12.K-Map in 3 Variables:
13.Simplified Expression of Input:
Conclusion

The project “LOGIC SIMPLIFICATION(LS)” is for computerizing the


working in a digital Labs. The software helps us to work easily and
conviently without any error and result into integrated circuits.
We can simplify a complex expression by Two methods:either by K-Map
or using various Theorems Provided.But The Limitation is that we can’t
make the proper use of theorems which is provided that’s mainly due to
shortage of time. We only have implemented the Theorems…..
The system provides a much gain if used effectively in electronics
Workshops.
Bibliography

1) Let Us C++ : Yashwant Kanetkar


2) Complete Reference C++ : Herbert Schildit
3) Programming with C++: Ravichandran
4) Digital Electronics “Eagle Prakashan” by Vipan Arora.
5) Google.com

S-ar putea să vă placă și