EE 200 Homework 2 Due via provide, 9/12 at 11:59pm `provide ee200 hw2 hw2.txt` Write your responses below the prompts. Please don't delete any of the existing text; you'll make the grader fail. For multiple choice, just put an 'x' or some other character in the brackets) 1) When the code below runs, what value will be printed? int f(int x){ return(2 + x * 5); } int g(int x, int y){ if(x > y){ return x; } else{ return y; } } int main(int argc, char* argv[]) { printf("result: %d\n", g(f(4), 15)); return(0); } (integer) 2) Rewrite this for loop as a while loop: for(int i = 0; i < 100; i++){ if(i % 10 == 0){ continue; } printf("i: %d\n", i); } (code) 3) When the code below runs, what value will be printed? int f(int x){ x = x + 1; return(x); } int main(int argc, char* argv[]) { int i = 0; f(i); f(i); f(i); f(i); printf("result: %d\n", f(i)); return(0); } (integer) 4) When the code below runs, how many times will "salamander!" be printed? Be careful! int f(int x){ printf("salamander!\n"); return(x); } int main(int argc, char* argv[]) { int i = 0; f(0); f(i); f(i++); if(f(i) || f(i++)){ printf("goodbye.\n"); } return(0); } (integer) 5) When the code below runs, how many times will "spotted newt" be printed? int main(int argc, char* argv[]) { for(i = 0; i >= 10; i++){ printf("spotted newt\n"); } return(0); } (integer) 6) Convert the following numbers to binary, using 8-bit 2's complement: -1, -14, -128, 8 (string) 7) Convert the following 8-bit 2's complement binary numbers to decimal: 10000011, 00001011, 11111100 (string) 8) Write a declaration for a struct representing a complex number, with double-precision floating point values for both the real and imaginary parts. (code) 9) Write a declaration for an enum defining the possible positions of a car's transmission. (code) 10) Given the declarations: int x = 5; float f = 2.1; char c = 'a'; What is the type and result of each of the following expressions? x + 2 x + f x + c f + c x / 2 x / 10.0 (free response) 11) Some embedded devices (i.e., very cheap low-power processors) do not have floating-point hardware, so performing a floating-point operation takes as much as 100 times longer than an integer operation. Rewrite the code below to use integer math (i.e., don't use `float` or `double`), while minimizing the loss of precision (i.e., it should give a result as close as possible to the floating-point version below). unsigned char calculate(unsigned char input) { float x = input; x = x / 256; float output = x * x * x; return((char)(output * 256)); } (code) 12) Write the declaration for a struct representing a rectangle (position and size) that will be displayed on your computer screen. Explain briefly why you chose the datatype(s) you did. (code) 13) DEAD and BEEF are two English words that are also valid hex numbers. Can you think of any others? (free response)