C Program to Display the Boolean Truth Table for AND,OR,NOT.

#include<stdio.h>


void main()
{
 int a[2][2],b[2][2],c[2];
 int i,j;
 for(i=0;i<=1;i++)
 {
 for(j=0;j<=1;j++)
  {
   a[i][j]=(i&&j);
   b[i][j]=(i||j);
  }
 }

 for(i=0;i<=1;i++)
 {
 c[i]=(!i);
 }

 printf("\nThe Truth Table for AND Gate( && ) is..\n");
 printf("   A    B     :    C=A&&B\n");
for(i=0;i<=1;i++)
 {
  for(j=0;j<=1;j++)
   {
    printf("   %d    %d     :    %d\n",i,j,a[i][j]);
   }
 }
 printf("\nThe Truth Table for OR Gate( || ) is..\n");
 printf("   A    B     :    C=A||B\n");
 for(i=0;i<=1;i++)
 {
  for(j=0;j<=1;j++)
   {
    printf("   %d    %d     :    %d\n",i,j,b[i][j]);
   }
 }
 printf("\nThe Truth Table for NOT Gate (!) is..\n");
 printf("   A   :  B = !A\n");
 for(i=0;i<=1;i++)
 {
   printf("   %d   :  %d\n",i,c[i]);
 }
}

9 comments:

  1. what can I do for such type of programming ? please help me..

    ReplyDelete
  2. Bro coding is done with zero error but program is not running what should i do?

    ReplyDelete
  3. gaand me danda maaru tere saale

    ReplyDelete
  4. Abe loude salle error aa rahi lund

    ReplyDelete
  5. ek dum sexy run hora hai vro , thankyou nigga

    ReplyDelete