Tuesday, February 10, 2015

C program to print truth table of XY Z

C++ program to print truth table of XY+Z

#include<iostream.h>
#include<conio.h>

void main()
{
int x,y,z;
clrscr();
cout<<"X Y Z XY+Z";

for(x=0;x<=1;++x)
for(y=0;y<=1;++y)
for(z=0;z<=1;++z)
{
if(x*y+z==2)
cout<<"

"<<x<<" "<<y<<" "<<z<<" 1";
else
cout<<"

"<<x<<" "<<y<<" "<<z<<" "<<x*y+z;
}
getch();
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.