Computer Science 101 Quiz 1 Name ______________________ ----- PLEASE ALSO WRITE YOUR NAME OF THE BACK OF THE PAPER ------ ----- PLEASE DO NOT FOLD THE PAPER ------ ----- You may leave when you finish ------ 1. Which of the following is NOT one of the three major classes of hardware components found in a computer system: a. processing elements b. programming elements c. storage elements d. communication elements 2. Which of the following is NOT part of the instruction set of the "human computer" discussed in class. a. halt b. sub c. jumpc d. start 3. The effect of the human computer instruction add 20,30,60 is to: a. store a 50 in box 60 b. store a 90 in box 20 c. store the sum of the values d. store the sum of the values found in boxes 20 and 30 in found in boxes 60 and 30 in box 50. box 20. 4. A compiler is a computer program whose typical mission is to: a. convert a assembly language code b. convert C language code to a high level language such as C to assembly language c. execute a program written in in assembly language. 5. The following program is designed to multiply integer values in box 100 and 101 and store the result in box 102. Box# 0 store 0,102 !initialize the sum 1 store 1,103 !initialize the incrementer 2 store 0,104 !initialize the counter 3 jumpc 100,eq,102,7 !Handle 0 multiplier 4 add 101,102,102 !add to the product 5 add 103,104,104 !increment the counter 6 jumpc 104,ne,101,4 !jump back to box 4 7 halt This program has an error that can be fixed by: a. changing box 2 to b. changing box 4 to store 1,104 add 100,101,102 c. changing box 6 to d. none of the above jumpc 104,ne,100,4 Computer Science 101 Quiz 2 Name ______________________ ----- PLEASE ALSO WRITE YOUR NAME OF THE BACK OF THE PAPER ------ ----- PLEASE DO NOT FOLD THE PAPER ------ 1. The number of bit in the "standard" byte found in all modern computers is a. 1 b. 8 c. 16 d. 32 2. Convert 1122 base 3 to base 10 3. Convert 152 base 10 to base 5 4. a. Write the value of the binary number 10100011 in hexadecimal b. Write the hexadecimal number 3C in binary 5. a. What is the binary twos complement of the value 00000001 b. The sum of a number x and its two's complement is a. 2x b. 1 c. 0 d. variable Computer Science 101 Quiz 3 Name ______________________ 1. a. The binary encoding 0110 0111 is the ascii encoding of what letter. (Be sure that your letter clearly shows the correct (upper/lower) case) b. What is the binary encoding of the case coverted encoding of the same letter 2. For each of the following data types, how many bits are used to store each variable of the type by the C compiler on the Sun systems we will be using in lab: ____ a. unsigned char ____ b. long ____ c. int ____ d. short 3. Circle all of the following variable names that would be ILLEGAL in a C program: a. _hello b. Hello c. 5ello d. Hello5 e. short f. sHorT 4. The following "C" program has two errors that must be corrected before it will compile correctly. For each line that contains a defect, write a corrected version of the line to the right of the defective line. #include stdio.h int main; { return(0); } Computer Science 101 Quiz 4 Name ______________________ 1. In the assignment statement n = fscanf(stdin, "%d %d %d", &x, &y, &z); if everything works correctly what should be the value of "n" a. 0 b. 1 c. 2 d. 3 2. Suppose my program contains: n = fscanf(stdin, "%d %d %d", &x, &y, &z); and I enter the values: 1234 56a7 9122 What values will be assigned to n, x, y, and z? If a variable will not be assigned a value just write "unchanged". n = x = y = z = 3. A basic block in a C program is delimited by a. () b. { } c. [ ] d. < > 4. What is the value (in base 10) of the following expression assuming v1 has the value 2 and v2 has the value 3. Assume v1 and v2 are int's and integer arithmetic is performed. v1 + (5 * (v2 / 3)) * 4 = 5. What is the output of the following program: int main() { int x; x = 11; if (x = 1) fprintf(stdout, "point 1 \n"); if (x == 1) fprintf(stdout, "point 2 \n"); if (x = 0) fprintf(stdout, "point 3 \n"); if (x == 0) fprintf(stdout, "point 4 \n"); } Computer Science 101 Quiz 5 Name ______________________ 1. This program which is attempting to read a single value from the standard input and write it to the standard output has three errors. #include int main() { int value; fscanf(stdin,"%d", value); value= 14; printf(stdout,"%d", value); return (0); } Identify each error and describe or show how to correct it. a - b - c - 3. This program whose objective is to print the sum of its input values has two errors #include int main() { int sum; // the sum of the single digit numbers int value; // the value just read int howmany; // howmany values were read howmany = fscanf(stdin, "%d", &value); while (howmany == 1) { sum = sum + 1; howmany = fscanf(stdin, "%d", &value); } fprintf(stdout, "The sum was was %d \n", sum); return(0); } Identify each error and describe or show how to correct it. a - b - Computer Science 101 Quiz 6 Name ______________________ 1. Consider the problem of computing the Fibonacci recurrence discussed in class last time. Identify the correct way to perform the basic update a. new = old + older; b. old = new; old = new; older = old; older = old; new = older + old; c. new = older + old; d. All are correct older = old; old = new; 2. Consider the problem of finding the maximum value in an input file. Suppose the value maxval is used to hold the maximum. At the start of the program maxval should be initialized to: a. 0 b. 10000000 c. -9999999 d. the first value in the file 3. Consider the problem of determining whether or not a program contains the number 13. The "yes" or "no" should be printed a. Within the while loop in b. After the while loop which values are read c. Both places 4. This program is intended to print the number of 3's in a file int main() { int counter; // the number of three's we've seen int value; // the value just read int howmany; // howmany values were read howmany = fscanf(stdin, "%d", &value); while (howmany == 1) { if (value = 3) counter = counter + 1; howmany = fscanf(stdin, "%d", &value); } fprintf(stdout, "The number of 3's was %d \n", counter); return(0); } It has two fatal errors in it. Identify them: a - b - Computer Science 101 Quiz 7 Name ______________________ 1. Suppose I wish to run an executable program called p4 and cause its standard input to be read from file called p4.txt. The proper way for me to do this is: a. p4 -i p4.txt b. p4 p4.txt c. p4 < p4.txt d. p4 - p4.txt 2. A color ppm image having dimension 200 rows by 300 columns contains how much image data: a. 500 bytes b. 60000 bytes c. 180000 bytes 3. The following is a correct ppm header: 50 36 0a 32 30 30 20 31 35 30 20 32 35 35 0a Suppose I build a solid color bright red image but When building the header if I accidentally add an extra space character to the header creating this: 50 36 0a 32 30 30 20 31 35 30 20 32 35 35 0a 20 ff 00 00 ff 00 00 .. a. it will have no adverse effect b. The image will appear when I view the image green instead of red c. the image will appear blue d. The image will appear instead of red purple instead of red 4. Suppose I declare an array as: int table[10]; The valid set of indexes that I can use to reference elements of the array are: a. table[0] ... table[10] b. table[1] ... table[10] a. table[0] ... table[9] b. table[0] ... table[10] 5. In C, if I accidentally use a value of ndx that is NOT in the valid set of indexes in the statement: table[ndx] = 100; a. the error will be detected b. Other data within my by the Operating System and program will be overwritten my program will be halted with a value of 100 and my immediately. program will continue. c. The array will be automagically d. Either (a.) or (b.) may changed in size so that no occur depending on the problem will occur. present value of ndx. Computer Science 101 Quiz 8 Name ______________________ 1. Suppose table[k] = 22 and table[k] = 44 and the following statements are executed: table[k + 1] = table[k]; table[k] = table[k + 1]; After these two statments are executed what values will be held in: table[k] = table[k + 1] = 2. Suppose table[k] = 22 and table[k] = 44 and the following statements are executed: temp = table[k + 1]; table[k] = table[k + 1]; table[k + 1] = temp After these two statments are executed what values will be held in: table[k] = table[k + 1] = 3. Suppose table[k] = 22 and table[k] = 44 and the following statements are executed: temp = table[k]; table[k] = table[k + 1]; table[k + 1] = temp After these two statments are executed what values will be held in: table[k] = table[k + 1] = 4. Considering the "swapping" problem in which the program proceeds from index 0 comparing each adjacent pair of values in the array and swapping values if table[k] > table[k + 1]. What is the correct output for this input: 4 19 3 4 25 1 7 5. Which of the following is NOT a technique which you should plan on using for debugging programs for the rest of your life: a. playing "human" computer b. using diagnostic prints c. use gdb d. e-mail Dr. Westall Computer Science 101 Quiz 9 Name ______________________ 1. The C language has no "official" "character string" data type. Instead character strings are represented by arrays of characters with the end of the string represented by: a. a byte of binary 0's b. the space character c. the new-line control d. the return control character character 2. Which of the following best characterizes the set of values that may be read with the %c format code a. only alphanumeric b. alphanumeric and characters special (!,@, #, etc) characters c. all of the above and control characters (newline, return, etc) as well. 3. When a string of characters is read into a character array using the %s format code, the end-of-string indicator (referenced in question 1) will be: a. automatically added by b. must be added by the program fscanf() c. must be present in the input data 4. When the %s format code is used to read a character string, reading will stop a. only when the end-of-string b. only when end-of-file occurs indicator is found in the in the input input c. whenever any "whitespace" character is found in the input. 5. When using fprintf the correct way to use the %c and %s format codes for the last parameter passed to fprintf to contain a. the address of the b. the value of the character character and the address to be printed but the address of the string in both of the string to be printed cases. c. the value of the character and the value of the string Computer Science 101 Quiz A Name ______________________ 1. Suppose I run a program as: a.out 400 300 The value of argc will be: a. 3 b. 2 c. 1 d. 4 2. If I want to assign the value of the first command line parameter (400 in problem 1) to an integer variable called width, the correct way to do so is: a. width = argv[1]; b. width = sscanf(argv[1], "%d"); c. sscanf(argv[1], "%d", width); d. sscanf(argv[1], "%d", &width); 3. Nesting of loops in the C language is restricted to a depth of no more than a. 1 b. 2 c. there is no specific limit 4. We considered two examples of the used of nested loops. (1) building a two dimensional image (2) counting the number of input characters that appear in a specific string In which of the examples was the use of a nested loop absolutely necessary: a. (1) only b. (2) only c. both (1) and (2) 5. In the two-d image example, the location of the col = 0; is row = 0; while (row < height) { col = 0; while (col < width) { a. incorrect and needs to be b. is correct as shown and moved to just after row = 0; moving it will break the program c. will work correctly in either place. Computer Science 101 Quiz B Name ______________________ 1. The basic strategy of the insertion sort algorithm that was presented in class was to: a. read all the the values into b. as each value was read in store it an array and then rearrange to the "front" (spot[0]) of the array them into sorted order and then move it to the correct spot. c. as each value was read in shift d. as each value was read in shift values to the "left" and then values to the "right" and then store the new value in the correct store the new value in the correct spot. spot. 2. Suppose int array[100] is being used in an insertion sort and its current values are array[0] = 2 and array[1] = 14. Further suppose that a value of 1 is read in next. After the value of 1 is inserted the new state of the array is a. {1, 2, 14} b. {0, 14, 1} c. {14, 2, 0, 1} d. {14, 2, 0} 3. Suppose the following code is executed char words[20]; int howmany; howmany = fscanf(stdin, "%s", &words[0]); while (howmany == 1) howmany = fscanf(stdin, "%s", &words[0]); and the contents of the standard input is: abc 123 xyz at EXIT from the loop a. words[0] contains the string b. words[0] contains 'a' "abc" words[1] contains "123" words[1] contains '2' and words[2] contains "xyz" words[2] contains 'z' c. words[0] contains 'a' c. words[0] contains 'x' words[1] contains 'b' words[1] contains 'y' words[2] contains 'c' words[2] contains 'z' 4. Suppose I declare the following values: char testword[] = "hello"; char hello[] = "hello"; If I then write the statements if (testword == hello) fprintf(stdout, "yes\n"); else fprintf(stdout, "no!\n"); the output I should expect is: a. no! b. yes Computer Science 101 Quiz C Name ______________________ 1. Which of the the following is syntactically correct a. int sum( b. int sum{ int a; int a, int b; int b, { } { } c. int sum( d. int sum( int a, int a, int b, int b) { } { } 2. According to the Linux kernel programming standard the number of local variables in a function should be limited a. 1 or 2 b. 5 to 10 c. 50 to 100 d. no more than 1000 3. According to the Linux kernel programming standard the length of a function should be related to its complexity as follows a. the more complex it is b. the more complex it is the longer it should be the shorter it should be 4. What value will be printed by the following program: #include int try_to_mod( int a) { printf("The address of try's a is %p\n", &a); a = 15; } main() { int a = 20; try_to_mod(a); printf("%d\n", a); } 5. What value will be printed by the following program: #include int addem( int a, int b) { int c; c = a + b; return(4); } main() { int sum; sum = addem(1, 2); printf(" \n", sum); } Computer Science 101 Quiz D Name ______________________ Correctly characterize the behavior of each of the following programs: a. Produces a compile time ERROR and no a.out b. Produces a compile time warning but produces correct output. c. Produces a compile time warning and incorrect output d. Compiles without warning and produces correct output. ____ 1. ____ 2. #include #include int main() int sum( { int a, int x; int b) { x = sum(11.0, 3); return(a + b); printf("%d \n", x); } return(0); } int main() { int sum( int x; int a, int b) x = sum(11.0, 3); { printf("%d \n", x); return(a + b); return(0); } } ____ 3. ____ 4. #include #include int main() { int main() int x; { int x; x = sum(5, 3); printf("%d \n", x); x = sum(11.0, 3); return(0); printf("%d \n", x); } return(0); } int sum( int a, float sum( int b) int a, { int b) return(a + b); { } return(a + b); } 5. Which of the following is a correct function prototype: a. int sum(a, b) b. int sum(int a, int b){}; c. int sum(int a, int) d. int sum(int a, int b); Computer Science 101 Quiz E Name ______________________ 1. Suppose the number of distinct values of type float is 2^32. The number of values that lie in the interval (-1, 1) is closest to: a. 2 b. 2 ^ 16 c. 2^31 2. The number of bits in the Exponent component of an IEEE 32 bit float is a. 1 b. 8 c. 23 d. 24 3. The fgetc() function a. reads at most one byte each b. may read more than one byte time it is called depending on the format code c. always consumes data until a newline is found. 4. The fgets() function a. reads a single byte from b. always reads a specified number a file of bytes from a file c. stops reading when it finds d. stops reading when it finds a a '\n' newline character or null character or fills the fills the specified buffer specified buffer space. space. 5. Suppose the fputs() function is called as follows: fputs(buf, stdout); Which best describes how the function will operate. a. A single byte stored at address b. bytes commencing at address buf buf will be sent to stdout will be sent to stdout until a \n (newline) character is found. c. bytes commencing at address buf will be sent to stdout until a NULL (binary 0) character is found. Computer Science 101 Quiz F Name ______________________ 1. How many bytes will be written by the following call to fwrite(). fwrite(buff, 4, 8, stdout); a. 4 b. 8 c. 12 d. 32 2. What value will be returned by the following call to fread() assuming end of file is NOT REACHED. rc = fread(buff, 4, 8, stdin); a. 4 b. 8 c. 12 d. 32 3. Suppose the parentheses beneath the "x's" are removed from the following program. What best characterizes the new behavior of the program x x while ((len = fread(buff, 1, 1024, stdin)) != 0) { fwrite(buff, 1, len, stdout); } a. It will have no effect on the b. It will cause the program program to exit the loop and 1 call to fread() c. It will cause the program to d. It will cause to program to read only 1 byte per call to write only 1 byte per call fread() to fwrite 4. What will be the value of y after the following code is executed: y = 4; p = &y; *p = 7; a. 4 b. 7 c. the address of y 4. Which best characterizes the behavior of the following program: main() { int *p; *p = 99; printf("The value is %d \n", *p); } a. The program is correct and b. The program is incorrect should be expected to work and will fail in all environments fine in all environments before the printf() is executed c. The program is incorrect, but it may appear to work correctly. Computer Science 101 Quiz G Name ______________________ 1. Suppose the following declarations are made in a program to be run on an Intel x86 computer. char *x; short *y long *z; a. Each of the three pointer b. The three pointer variables consume variables consumes 4 bytes 1, 2, and 4 bytes respectively of space. c. Each of the three pointer variables consumes 1 byte of space. 2. Which best characterizes the behavior of the following program: main() { int *pi; pi = (int *)malloc(4); scanf("%f", &pi); } a. The program will correctly b. The program is incorrect. read a single floating point The & in the scanf() call must into the malloc'd memory be deleted to fix it. c. The presence of the & is optional.. The program will read the value into the malloc'd memory either way. 3. Which is the proper way to dynamically allocate storage for an array of 100 integers. (For questions 2, 3, 4 assume that the pointer variable pi is declared as: int *pi; a. pi = (int *)malloc(4 * 100); b. pi = (int *)malloc(100); c. pi = (int *)malloc(4 * sizeof(int)); 4. Suppose the values of the 100 integers are to be printed in a for () loop. In each interation through the loop, the proper way to update the pointer used to point to the value to be printed is: a. pi = pi + 4; b. pi = pi + 1; c. pi = pi + sizeof(int); d. pi = pi + 100; 5. The proper way to print the value of the current integer is: a. printf("%d \n", &pi); b. printf("%d \n", pi); c. printf("%d \n", *pi); d. printf("%d \n", **pi); Computer Science 101 Quiz H Name ______________________ 1. The correct way to access a green pixel in the input image is: a. in_image[3 * inrow * incols + 3 * incol + 3] b. in_image[3 * inrow * incols + incol + 1] c. in_image[3 * inrow * incols + 3 * incol + 1] d. in_image[3 * incol * inrows + 3 * inrow + 1] 2. Suppose int inrows = 400, int outrows = 800, and int row = 100; What is the value of the expression: row / outrows * inrows a. 200 b. 50 c. 0 3. Correct way to write out the grayscale pixel data is: a. fwrite(out_image, 3, outrows * outtcols, stdout); b. fwrite(out_image, 1, outrows * outcols, stdout); c. fwrite(stdout, 3, outrows, outcols, out_image); 4. The correct way to access a gray pixel in the output image is: a. out_image[3 * row * outcols + col] b. out_image[row * outcols + col] c. out_image[col * outrows + row] d. out_image[3 * row * outcols + 3 * col] Computer Science 101 Quiz I Name ______________________ 1. Identify the correct implementation of the "swap" function. void swap(int *x, int *y) a. int *temp; b. int temp; *temp = *x; *temp = x; *x = *y; x = y; *y = *temp; y = temp; c. int temp; d. int temp; *temp = *x; temp = *x; *x = *y; *x = *y; *y = *temp; *y = temp; 2. Identify the correct way to obtain an image width from a command line parameter void getwidth(int argc, char *argv[], int *width) { a. sscanf(argv[1], "%d", &width); b. sscanf(argv[1], "%d", width); c. sscanf(argv[1], "%d", *width); 3. Suppose array has been declared as int array[10] and ndx as int ndx; Which of the following formulations are equivalent expressions: (Identify all of them) a. array + ndx and b. array + ndx and array[ndx] &array[ndx] c. *(array + ndx) and d. *(array + ndx) and array[ndx] &array[ndx] 4. In this program the 3 declarations of y will int y = 52; int main() { int y = 34; a. will result in there being { three separate locations int y = 77; in which a variable named printf("%d ", y); y is stored. } printf("%d \n", y); } b. cause a syntax error for c. will result in all three duplication of declaration declarations referring to the same memory location. 5. The output of the program will be: a. no output at all b. 77 77 c. 77 52 d. 77 34 Computer Science 101 Quiz J Name ______________________ 1. Identify all of the variables that will reside on the STACK int r; void fun(int s) a. a b. s { int t; static int u; c. t d. u : return; } 2. Suppose the declaration of r in the above program is changed to static int r; The effect of this change is that a. The variable will live on b. If code in another source code (.c) the stack instead of the wishes to reference the variable r, heap. extern int r; must be specified c. Code in another source code module will be unable to reference the variable r 3. In the function in problem 1 which of the following variables can be expected retain their values from one invocation of fun() to the next: a. both t and u b. t but not u c. u but not t d. neither t nor u 4. Given the following definitions circle ALL of the following assignments that are syntactically correct: struct pix struct pix p1; { struct pix* p2; unsigned char r; unsigned char g; unsigned char b; }; a. p1->r = 250; b. p2.r = 250; c. (*p1).r = 250; d. p1.r = 250; 5. In the definition: struct pix pixel; a. both pix and pixel are types and b. pix is a type but pixel is not instances of variables an instance c. pixel is a type and pix is an d. both pixel and pix are instances instance of a variable of variables. Computer Science 101 Quiz K Name ______________________ struct pix_type { unsigned char r; unsigned char g; unsigned char b; }; struct pix_type *pptr; struct pix_type p; 1. Given the definitions above write the value of each of the following: ____ a. sizeof(pptr) ____ c. sizeof(struct pix_type *) ____ b. sizeof(*pptr) ____ d. sizeof(p) 2. Given the following structure definition, which of the following is syntactically correct. struct new a. v[1].a[1] = 1; b. v[0].b[1] = 1; { int a; c. v.b[1] = 1.5; d. v.a[1] = 1.5; float b[2]; }; struct new v[3]; 3. Given the following structure definition, which of the following is syntactically correct. struct new a. v[1].a = 1; b. v.a[1] = 1; { int a[2]; c. v.b[1] = 1.5; d. v[1].b = 1.5; float b; }; struct new v; 4. Given the following two structures: struct image struct pix { { int rows; unsigned char r; int cols; unsigned char g; struct pix pixmap[1024][768]; unsigned char b; }; }; the order in which the structure definitions appears in a program must be: a. struct image before b. struct pix before struct pix struct image c. Either way works fine Computer Science 101 Quiz L Name ______________________ 1. The number of ints created by the following declaration int twod[3][6]; a. 9 b. 10 c. 18 d. 36 2. Which of the following is the correct way to pass the address of row 2 of the array to a function declared as fun(int *vals); a. fun(twod) b. fun(twod[2][0]) c. fun(&twod[2]) d. fun(twod[2]) 3. Which of the following array elements lies nearest in memory to twod[0][0] a. twod[0][5] b. twod[1][1] c. twod[1][0] d. twod[2][5] 4. Suppose three adjacent pixels have the values 10, 15, 20 What is the inner product of these three values with a row of a filter which has the values 0.1 0.2 and 0.1. 5. Suppose the inner_product function has the following header: unsigned char inner_prod( struct pix_type *pix, float *filt) the proper way to compute a single element of the inner product is: a. sum = sum + pix.g * filt; b. sum = sum + pix->g * filt; c. sum = sum + pix->g * (*filt); d. sum = sum + pix.g * (*filt); Computer Science 101 Quiz M Name ______________________ struct work_type { int w[1024 * 1024]; }; struct work_type work; struct work_type *pwork = &work; 1. Which of the following function calls will cause 4MB of data to be copied onto the stack: a. fun1(pwork); b. fun2(work); c. both d. neither 2. Which of the following function class will allow the called function to modify the caller's copy of the structure. a. fun1(pwork); b. fun2(work); c. both d. neither 3. Which best defines the way "const" works here: void fun1(const struct work_type *q) { } a. It is like a comment but has b. It will cause a compile time no real effect error if the function contains: q->w[0] = 100; but other backdoor approaches c. It makes it completely can still be used to modify the impossible for fun1 to structure make any change to the structure 4. Consider these two function prototypes (1) struct work_type fun3(void); (2) struct work_type *fun4(void); Which return from the function will cause 4MB to be copied a. fun3() b. fun4() c. both d. neither 5. Passing a large array (which is NOT embedded in a structure to a function can causes the array to be copied onto the stack a. always b. never c. it depends on whether the array is passed using the name &array[0] or just using the name array Computer Science 101 Quiz N Name ______________________ 1. The "break" statement will cause a program to exit: a. an "if statement" b. a loop c. both d. neither 2. Which is the correct use of ; in the following: a. while () do b. while (); do { { { { } } while () } } while (); c. while (); do d. while () do { { { { } } while () } } while (); 3. What output would be produced by the following code fragment: x = 5; switch(x) { case 5: printf("5\n"); case 7: printf("7\n"); break; default: printf("none\n"); } 4. What output would be produced by the following code fragment: y = 11; x = 2; z = (y < x)? (x + 1): (y - 1); printf("%d\n", z); 5. Consider the following code fragment i = 0; while (i < 10) { if (x > y) continue; i = i + 1; } Suppose x = 10 and y = 0 at the start of the loop. What will happen?? Computer Science 215 Quiz O Name ______________________ 1. If a C program mallocs an area of memory and fails to free it, a. A garbage collector built b. The OS will reclaim all of the into the C language will memory used by the program including reclaim it unfreed malloc'd areas when the program exits. c. The memory will remain unusable d. The memory will remain permanently until the system is rebooted allocated and the computer will eventually have to be sent back to the factory for memory replacement 2. Suppose a buffer is declared as a local variable as follows: unsigned char buffer[512]; The function that contains the declaration a. must include a free(buffer); b. must NOT do free(buffer); to avoid a memory leak c. may do a free(buffer) but if it doesn't there will be no leak 3. Assuming "lst" points to the head a list of structures of type obj_t, best characterizes the following code fragment: obj_t *temp = malloc(sizeof(obj_t)); temp = lst->head; a. it will cause a memory leak b. it will cause a seg fault c. it is the correct way to set temp to point to the first object in the list. 4. Which would be the best way to reformulate the above code: a. obj_t *temp = malloc(sizeof(obj_t)); b. obj_t *temp = NULL; free(temp); temp = lst->head; temp = lst->head; c. The code was PERFECT as it was annd should be reformulated 5. What best describes this reformulation: obj_t *temp = malloc(sizeof(obj_t)); free(temp); temp = lst->head; a. The call to free() will cause b. Its mildly inefficient a seg fault. but won't cause any major problem c. It creates a major memory leak