Professional Documents
Culture Documents
Assign 6
Assign 6
EXPERIMENT No. - 6
DESCRIPTION: Basic gates AND,OR,NOT accepts input and gives a particular output.AND gives
true when both input are true , OR gives true when either of the input is true, NOT gate inverses the
input i.e, true gives false and false gives true.
CODE:
#include <stdio.h>
int ttand(int a,int b)
{
if(a==1&&b==1)
return 1;
else
return 0;
}
int ttor(int a,int b)
{
if(a==1||b==1)
return 1;
else
return 0;
}
int ttnot(int a)
{
if(a==0)
return 1;
else
return 0;
}
int main()
{ int ch,res,A,B;
printf("\n1. print the truth table of AND");
printf("\n2. print the truth table of OR");
printf("\n3. print the truth table of NOT");
printf("\nEnter the choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
for(A=0;A<=1;A++){
for(B=0;B<=1;B++){
res=ttand(A,B);
printf("%d\t%d\t%d\n",A,B,res);
}
}
break;
case 2:
for(A=0;A<=1;A++){
for(B=0;B<=1;B++){
res=ttor(A,B);
printf("%d\t%d\t%d\n",A,B,res);
}
}
break;
case 3:
for(A=0;A<=1;A++){
res=ttnot(A);
printf("%d\t%d\n",A,res);
}
break;
case 4:
break;
}
return 0;
}
OUTPUT: