In C using bit operators
methodOne- returns value with n upper bits set to 1
and 32-n lower bits set to 0
You may assume 0 <= n <= 32
Example: methodOne(4) = 0xF0000000
Legal ops: ! ~ & ^ | + << >>
Answer
#include <stdio.h>int methodOne(int n) { return ((1 << 31) >> n) << 1;}int main() { printf(“0x%xn”, methodOne(4)); return 0;}