CS 215: UNIX C Programming

Review for Quiz 3
 
  1. 1. Direct input, or the immediate echoing of input characters, is an instance of _____ input.
    1. buffered
    2. unbuffered
    3. bufferless
    4. buffed


  2. All of the following are advantages of buffered input except which one of the following?
    1. Less time consuming to transmit characters.
    2. Allows for keyboard corrections before transmission.
    3. Especially suited for games like Doom
    4. Allows only the corrected version to be displayed.


  3. A ___ is an area of memory in which information is stored.
    1. fence
    2. fact
    3. farm
    4. file


  4. In C, keyboard input is represented by a stream called ___ and output is represented by a stream called ___.
    1. in, out
    2. str_in, str_out
    3. stin, stout
    4. stdin, stdout


  5. In UNIX or DOS, which one of the following is a redirection operator?
    1. ?
    2. :
    3. <
    4. =


  6. Which one of the following allows you to run a copy program, named echo_eof.exe, to make a copy of the file, myword, and to save the copy as a file named, saveword?
    1. echo_eof.exe > myword < saveword
    2. echo_eof.exe < myword < saveword
    3. echo_eof.exe < myword > saveword
    4. echo_eof.exe > myword > saveword


  7. Writing C statements that require the computer to determine if user input falls within an acceptable range is called ______.
    1. error-checking
    2. keyboard control
    3. irritating programming
    4. range building


  8. Which DOS character entered at the keyboard is used to simulate the end-of-file condition in UNIX?
    1. control-D
    2. control-P
    3. control-C
    4. control-Z


  9. Interspersing calls to getchar() and scanf() can cause problems when scanf() leaves ___ in the input, just before a call to getchar().
    1. \t
    2. \n
    3. \0
    4. \Z


  10. Which UNIX (and DOS) character is used to add data to the end of an existing file?
    1. !!
    2. >>
    3. ||
    4. //


  11. A function is a self-contained unit of program code design to _____.
    1. replace main()
    2. trap all input errors
    3. accomplish a particular task
    4. avoid I/O files


  12. Functions do all of the following EXCEPT
    1. Make a program easier to read.
    2. Make a program more modular.
    3. Make a program easier to repair.
    4. Make a program bug free.


  13. Which of the following best explains the statement void starbar(void)
    1. function prototype
    2. function definition
    3. function call
    4. function declaration


  14. What is another way of writing the following statements?
    if (n < m)
    return (n);
    else
    return (m);
    1. return (n < m) ? n : m;
    2. (n < m) return ? n : m;
    3. return (n < m) ? return (n) : return (m);
    4. return (n < m) ? return (n : m);


  15. A function with no return value should be declared as type ___.
    1. void
    2. int
    3. null
    4. float


  16. A function ___ informs the compiler which type the function is, but the function ___ supplies the actual code.
    1. definition, call
    2. declaration, definition
    3. definition, declaration
    4. call, declaration


  17. When a function calls itself, it is termed ___.
    1. recession
    2. recessing
    3. receiving
    4. recursion


  18. What is the maximum number of times a function can call itself?
    1. zero
    2. once
    3. twice
    4. There is no upper limit.


  19. With a recursive call, each call is balanced with a ___.
    1. prototype
    2. return
    3. argument
    4. EOF


  20. Although each level of recursion has its own ____, the ___ itself is not duplicated.
    1. parameters, recursive call
    2. argument list, function
    3. set of variables, code
    4. prototype, function call


  21. Binary notation represents numbers in terms of powers of ___
    1. 0 or 1
    2. 2
    3. 10
    4. Both a and b are correct.


  22. In which directory would the following include file be found?
    #include "hotels.h"
    1. system library directory
    2. current working directory
    3. system .h directory
    4. main .h directory


  23. A pointer is a variable used to store a(n) ____.
    1. operand
    2. operator
    3. variable
    4. address


  24. Which of the following statements will display the address of the variable pooh, where pooh = 24;
    1. printf(" %d", &pooh);
    2. printf(" %d", *pooh);
    3. printf(" %p", &pooh);
    4. printf(" %p", *pooh);


  25. In C, each function uses ___ variables.
    1. it's own
    2. shared
    3. duplicate sets of
    4. common


  26. Which of the following completes the swap of the variables x and y, given the statements
    temp = x;
    x = y;
    1. y = x;
    2. y = temp;
    3. x = temp;
    4. temp = y;


  27. ___ is a pointer variable and ___ may be a regular variable, given the statement ptr = &pooh;
    1. ptr, pooh
    2. pooh, ptr
    3. Both a and b are correct.
    4. None of the above are correct.


  28. Which of the following statements finds the value (val) that ptr, a pointer variable, points to?
    1. val = & ptr;
    2. val = * ptr;
    3. ptr = & val;
    4. ptr = * val;


  29. Which of the following declares pi as a pointer to int?
    1. int pi;
    2. int * (&pi);
    3. int & pi;
    4. int * pi;


  30. Which of the following passes the address of x and y to the function change_them()?
    1. change_them( &x, &y);
    2. change_them( x, y);
    3. change_them( *x, *y);
    4. change_them( &(*x), &(*y));


  31. Given the following function call, which of the following function headings is correct?
    change_it (&x, &y);
    1. void change_it (int x, int y)
    2. void change_it (int &x, int &y)
    3. void change_it (int *x, int *y)
    4. void change_it (*int x, *int y)


  32. What are the values 5 and 2, given that they are assigned to a and b, respectively, in the statement
    c = diff(a, b);
    1. formal arguments
    2. informal arguments
    3. actual arguments
    4. pointer arguments


  33. Functions must have the same ___ as the value they return.
    1. value
    2. type
    3. address
    4. argument