Answer to Question #294607 in Discrete Mathematics for Yaku

Question #294607

a) Consider the function, bin, that converts an integer to a binary digit as:

bin : Z 6{-1, 0, 1}, bin(x) = x congruence modulo 2.


Now, define the logical NOT function as:

NOT: Z"\\to" {0, 1}, NOT(x)="\\begin{Bmatrix}\n 0, if x != 0\\\\\n 1, if x=0 \n\\end{Bmatrix}"


i) Write C++ code for the logical NOT function specified above.


ii) Using the function defined in i) above, write in C++ the polymorphic logical exor

function:

int exor(int x, int y):- it returns x r y

int exor(int * bits, int N):- it returns the exor of the N binary integers, bits.


b) As a result of a) above, write in C++ the polymorphic logical not exor function,

nexor:

int nexor(int x, int y):- it returns the negation of x r y

int nexor(int * bits, int N):- it returns the nexor of the N binary integers, bits


0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS