Writing Errands

Write C function hwk1a, that takes a long int x as argument as well as two integers n and m, and returns a long int. Here is the function declaration: long int hwk1a (long int x, int n, int m); The function should swap byte n and m of a long int x (64-bit integer). A byte is an eight-bit aggregation. For this problem the index of the least significant byte is 0, and the index of the most significant byte 7 (so 0 <= m, n <= 7). So, if x = 0x0123456789ABCDEF (a 64-bit integer), and if you swap two bytes say that are at the 3 rd and 5th index, x would now be x=0x0123896745ABCDEF. You are not allowed to use division, multiplication, or modulus, relative comparisons (<, >, <=, >=), loops, switches, function calls, macros, conditionals (if or ?:) You are allowed to use all bit level and logic operations, left and right shifts, addition and subtraction, equality and inequality tests, integer constants (<=255), INT_MIN and INT_MAX, and casting between data types.

× Chat on WhatsApp