Review Questions

I l @ ve RuBoard

Review Questions

  1. Which storage classes create variables local to the function containing them?

  2. Which storage classes create variables that persist for the duration of the containing program?

  3. Which storage class creates variables that can be used across several files? Restricted to just one file?

  4. What might make the sorting algorithm inefficient?

  5. How would you change the sorting routine to make it sort in increasing order instead of decreasing order?

  6. How would you change getarray() to handle strings that represent octal numbers ?

  7. Which functions know each variable in the following? Are there any errors?

     /* file 1 */ int daisy; int main(void) {   int lily;   ...; } int petal() {   extern int daisy, lily;   ...; } /* file 2 */ extern int daisy; static int lily; int rose; int stem() {   int rose;   ...; } void root() {   ...; } 
  8. What will the following program print?

     #include <stdio.h> char color= 'B'; void first(void); void second(void); int main(void) {   extern char color;      printf("color in main() is %c\n", color);   first();   printf("color in main() is %c\n", color);   second();   printf("color in main() is %c\n", color);   return 0; } void first(void) {   char color;   color = 'R';   printf("color in first() is %c\n", color); } void second(void) {   color = 'G';   printf("color in second() is %c\n", color); } 
  9. A file begins with the following declarations:

     static int plink; int value_ct(const int arr[], int value, int n); 
    1. What do these declarations tell you about the programmer's intent?

    2. Will replacing int value and int n with const int value and const int n enhance the protection of values in the calling program?

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net