Computer Science, asked by shziaanjum, 4 days ago

write a program to calculate to input two values from user and use all arithmetic operator .(add, subtract, exponent ect .​

Answers

Answered by poojashukla1911
0

Answer:

Write a function Add() that returns sum of two integers. The function should not use any of the arithmetic operators (+, ++, –, -, .. etc).

Sum of two bits can be obtained by performing XOR (^) of the two bits. Carry bit can be obtained by performing AND (&) of two bits.

Above is simple Half Adder logic that can be used to add 2 single bits. We can extend this logic for integers. If x and y don’t have set bits at same position(s), then bitwise XOR (^) of x and y gives the sum of x and y. To incorporate common set bits also, bitwise AND (&) is used. Bitwise AND of x and y gives all carry bits. We calculate (x & y) << 1 and add it to x ^ y to get the required result.

Explanation:

thank you for your question and make me brilliant please

Similar questions