Computer Science 215 Quiz 3 Name ______________________ 1. If a C program is to read from the standard input using fscan(stdin, "%d", &c); a. The program must contain a b. The program must contain a FILE *stdin; FILE stdin; declaration. declaration. c. The program must NOT declare stdin because it must be predeclared in stdio.h 2. Which best characterizes the action taken when reading a file with fscanf() and with fgetc() a. fscanf() may consume multiple b. both fscanf() and fgetc() bytes from the file in a single consume exactly one byte call, but a call to fgetc() will per call. consume at most 1 byte. c. both fscanf() and fgetc() consume multiple bytes per call. 3. 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. 4. Consider the following program fragment: unsigned int c; c = fgetc(stdin); fprintf(stdout, "%d\n", c); Now suppose I run the program and type number 3 followed by a ctl-d (EOF). The value printed on my screen will be: (Hint: the ASCII encoding of the character '3' is 0x33 = 51.) a. 3 b. 51 c. c d. \n 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 location b. The value "buf" will be interpreted buf will be sent to stdout as a pointer and whatever byte it points to will be sent to stdout. c. "buf" will be viewed as a pointer d. "buf" will be viewed as a pointer and bytes starting at the location and bytes starting at the location to which it points will be sent to which it points will be sent to stdout until a \n (newline is to stdout until a NULL (byte having found) the value 0 is found)