I have the following code below, i am trying to add xnorr,norr,nandd function to it, how would i do this
Code:
char nott(char operand);
char andd(char operand1, char operand2);
char orr(char operand1, char operand2);
char xorr(char operand1,char operand2);
#define PREFERRED 'p'
#define OTHER 'o'
#define INVALID 'x'
char nott( char operand )
{
char result=INVALID;
if (operand == PREFERRED )
result=OTHER;
else
result=PREFERRED;
return (result);
}
char andd(char operand1, char operand2)
{
char result=INVALID;
if (operand1==PREFERRED)
{
if (operand2==PREFERRED)
{
result=PREFERRED;
}
else if (operand2==OTHER)
{
result=OTHER;
}
}
else if(operand1==OTHER)
{
if(operand2==OTHER)
{
result=OTHER;
}
else if (operand2==PREFERRED)
{
result=OTHER;
}
}
return (result);
}
char orr(char operand1, char operand2)
{
char result=0;
result=INVALID;
if (operand1 == PREFERRED)
result = PREFERRED;
else if (operand2==PREFERRED)
result = PREFERRED;
else
result = OTHER;
return (result);
}
char xorr(char operand1,char operand2)
{
char result=orr(andd(nott(operand1),operand2),andd(nott(operand2),operand1));
return(result);
}
char nandd(char operand1,char operand2)
{
char result=INVALID;
result=nott(andd(operand1,operand2));
return(result);
}