Lab 02 Finding your endianness solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (2 votes)

Lab 02

Finding your endianness
Download the endian.c file to your computer. Compile it with clang -Wall endian.c. Now pick a three
letter word and look up the hexadecimal values in the ASCII table (along with the newline character). Create
the proper 4-byte int to create that string. What is the endianness of your computer???
Greatest common divisor
The greatest common divisor (GCD) of two numbers can be found by using Euclid’s algorithm. Implement
the recursive Euclidean algorithm to solve the GCD of various values.
Finding a particular Fibonacci number is easy: given F(1) = F(2) = 1, one can build successively bigger
values with the recurrence F(n) = F(n-1) + F(n-2). The problem is that lots of computation is repeated using
this method. One approach is to store the results of previous computation. For example, filling in an array
with sentinel values of zero will let you check if that value has been computed already. If, for example, F(x)
is non-zero then that value has already been computed and you can return that partial solution. Otherwise,
you must compute F(x) as usual, possibly utilizing some pre-computed values. Prepend the time command
to your normal command line e.g., time ./a.o