Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a C program for fourier that repeatedly reads input from a file and proces

ID: 3886992 • Letter: W

Question

write a C program for fourier that repeatedly reads input from a file and processes it. Each input consists of an integer, two endpoints specifying a substring of the integer, and a flag. We select the specified substring and print it out in hex and as an unsigned, 1’s complement, or 2’s complement integer, depending on the flag ('u', '1', or '2'). For example, an input of 1234abcd 8 4 u asks to find bits 8:4 of 1234abcd, which turn out to be the 5 bits 11100, so we print hex 1c and 28 (the interpretation of 11100 as a 5-bit unsigned integer). We would have printed -3 for a flag of '1' and -4 for a flag of '2'

Explanation / Answer

1. Aisume that in file each line indicates one input like '1234abcd 8 4 u'

2. Aisume that each parameter is seperated by single space ' '

Sample Input file :-

----------------------------------------

1234abcd 8 4 u
1234ffcd 10 2 u
abc4abcd 8 4 1
ff34ff12 10 2 2

Programme :-

------------------------------

--------------------------

Result is :: 0x1c0

Result is :: 0x9cc

Result is :: 0xfffff433

Result is :: 0xffffecf0