#include <iostream>
#include <conio>
void And();
void oR();
void main()
{
char y;
while(1)
{
cout<<"\tPress A for And gate operation\n\tPress R for OR gate\n";
cin>>y;
if(y=='A')
{ And(); }
else
if(y=='R')
{
oR();
}
}
getch();
}
/**********************************************/
void And()
{
int a,b;
cout<<"Enter first binary formated input\t";
cin>>a;
cout<<"Enter 2nd binary formated input \t";
cin>>b;
if(a==0&&b==0||a==0&&b==1||a==1&&b==0)
{cout<<" -------\n";
cout<<a<<"------| \""<<"------0"<<endl;
cout<<b<<"------| AND /\n";
cout<<" ------\n"; }
else
if(a==1&&b==1)
{
cout<<" -------\n";
cout<<a<<"------| \""<<"------1"<<endl;
cout<<b<<"------| AND /\n";
cout<<" ------\n"; }
}
/*******************************************/
void oR()
{ int a,b;
cout<<"Enter first binary formated input\t";
cin>>a;
cout<<"Enter 2nd binary formated input \t";
cin>>b;
if(a==1||b==1&&a==0||b==1&&a==1||b==1)
{ cout<<" -------\n";
cout<<" -------\n";
cout<<a<<"------| \""<<"------1"<<endl;
cout<<b<<"------| AND /\n";
cout<<" ------\n";
cout<<" -------\n"; }
else
if(a==0&&b==0)
{ cout<<" -------\n";
cout<<" -------\n";
cout<<a<<"------| \""<<"------0"<<endl;
cout<<b<<"------| OR /\n";
cout<<" ------/\n";
cout<<" -------/\n";
}
}
0 comments:
Post a Comment