What is wrong in the code, I have to prove they are logically equavialent. Check it's output code, one line missing.

0 votes
asked Jun 18, 2019 by ramesh harmel (120 points)
#include<stdio.h>

#include<conio.h>

#include<string.h>

int main()

{

char tp,tq,tr;

char a[10];

char b[10];

char c[10];

char lhs[10];

char rhs[10];

int i,j,k,l=0;

printf("\np\tq\tr\tp-->r\tq-->r\t(p-->q)^(q-->r)\tpVq\t(pvq)--->r)");

printf("\n________________________________________________________________________________________________");

for(i=0;i<=1;i++)

{

if(i==0)

   tp='T';

else

   tp='F';

for(j=0;j<=1;j++)

{

if(j==0)

  tq='T';

else

tq='F';

for(k=0;k<=1;k++)

{

if(k==0)

  tr='T';

else

  tr='F';

printf("\n%c\t%c\t%c",tp,tq,tr);

if(tp=='T'&&tr=='F')

{

a[l]='F';

printf("\t%c",a[l]);

}

else

{

a[l]='T';

printf("\t%c",a[l]);

}

if(tq=='T'&&tr=='F')

{

b[l]='F';

printf("\t%c",b[l]);

}

else

{

b[l]='T';

printf("\t%c",b[l]);

}

if(a[l]=='T'&&b[l]=='T')

{

lhs[l]='T';

printf("\t%c",lhs[l]);

}

else

{

lhs[l]='F';

printf("\t%c",lhs[l]);

}

if(tp=='F'&&tq=='F')

{

c[l]='F';

printf("\t\t%c",c[l]);

}

else

{

c[l]=='T';

printf("\t\t%c",c[l]);

}

if(c[l]=='T'&&tr=='F')

{

rhs[l]='F';

printf("\t%c",rhs[l]);

}

else

{

rhs[l]='T';

printf("\t%c",rhs[l]);

}

l++;

}

}

}

k=0;

for(i=0;i<8;i++)

{

if(lhs[i]==rhs[i])

k++;

}

if(k==8)

  printf("\nequal");

if(strcmp(lhs,rhs)!=0)

  printf("\n Both propositions are logically equivalent");

return 0;

}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...