Hello, I am trying to solve a problem that has to do with bit representation and
ID: 3549278 • Letter: H
Question
Hello,
I am trying to solve a problem that has to do with bit representation and it has certain limits, as to what kind of controls and the amount that I can use for this particular problem. These controls linclude:
Using if, do, while, for, switch, etc.
defining additional functions
calling any functions
using any form of casting
using operations such as &&, ||, -, or ?:
using any data type other than int
defining or using macros
My goal is to replace the "return" statement in each function with one or more lines of c code that implements the function.
here is my problem:
int bitAnd(int x, int y)
//code implementation
return 2
I am confused as to how to look at this problem or how to start. Does anyone have any suggestions?
Explanation / Answer
int bitAnd(int x,int y){
int p = x*y; // p would be equal to 1 when both x and y are equal to one else p willl be 0
return p;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.