Guess you have to add two integers or numbers but without using the arithmetic operator. You cannot use any arithmetic operator like +, -, ++, --, ... etc. How will you do that? This question was asked in Microsoft Online Assessment. For solving this problem we have to go back to our Digital Electronics concepts where for adding two bits, we can do the XOR(^) of those bits. if they have a carry, we can find that out by applying AND(&) of them. So, this is the simple concept of Half Adder which is used to add 2 single bits. Input: 3 5 Output: 8 C++ code for this problem: #include <bits/stdc++.h> using namespace std ; int main () { int x, y, carry; cin >> x >> y; while (y != 0 ) { carry = x & ...
TechNetizs is a blog covering technology related news and focused on sharing Coding related information and projects.