Truth Table for XY+Z
X Y Z XY+Z
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
/* Logic is
if Z is 1 then output is 1 ;
or
if X and Y both are 1 , the output is 1 . */
void main()
{
clrscr();
cout<< "Truth Table\n";
cout<< "X\t Y\t Z\t\t XY+Z \n\n";
for(int i = 0 ; i<=1 ; i++)
for(int j = 0; j<=1; j++)
for(int k = 0; k<=1; k++)
{
cout<< i<< "\t"<< j << "\t" << k << "\t\t";
if( (i == 1 && j == 1) || k == 1)
cout<< 0;
else
cout<< 1;
cout<<"\n";
}
getch();
}
X Y Z XY+Z
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
/* Logic is
if Z is 1 then output is 1 ;
or
if X and Y both are 1 , the output is 1 . */
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
cout<< "Truth Table\n";
cout<< "X\t Y\t Z\t\t XY+Z \n\n";
for(int i = 0 ; i<=1 ; i++)
for(int j = 0; j<=1; j++)
for(int k = 0; k<=1; k++)
{
cout<< i<< "\t"<< j << "\t" << k << "\t\t";
if( (i == 1 && j == 1) || k == 1)
cout<< 0;
else
cout<< 1;
cout<<"\n";
}
getch();
}
There is a mistake.. it shud be
ReplyDeleteif( (i == 1 && j == 1) || k == 1)
cout<< 1;
else
cout<< 0;
U r right..
Deletewhat about this??
ReplyDelete#include(iostream)
#include(conio.h)
using namespace std;
void main()
{
int X,Y,Z;
int xyPlusZ;
cout<<"\t\tTRUTH TABLE \n"
<<"X\tY\tZ\t(XY)+Z\n"
<<"---\t---\t---\t---\n\n"; // for the table 1st row
for(X=0;X<=1;X++)
{
for(Y=0;Y<=1;Y++)
{
for(Z=0;Z<=1;Z++)
{ xyPlusZ=((X&&Y)||Z); // for the value
cout<<X<<"\t"<<Y<<"\t"<<Z<<"\t"<<xyPlusZ<<endl; // table content
}
}
}
getch();
}