Review Questions

I l @ ve RuBoard

Review Questions

  1. putchar ( getchar ()) is a valid expression; what does it do? Is getchar(putchar()) also valid?

  2. What would each of the following statements accomplish?

    1. putchar('H');

    2. putchar('\007');

    3. putchar('\n');

    4. putchar('\b');

  3. Suppose you have a program count that counts the characters in its input. Devise a command that counts the number of characters in the file essay and stores the result in a file named essayct .

  4. Given the program and files in Question 3, which of the following are valid commands?

    1. essayct <essay

    2. count essay

    3. essay >count

  5. What is EOF ?

  6. What is the output of each of the following fragments for the indicated input (assume that ch is type int and that the input is buffered)?

    1. The input is as follows :

       If you quit, I will.[enter] 

      The fragment is as follows:

       while ((ch = getchar()) != 'i')          putchar(ch); 
    2. The input is as follows:

       Harhar[enter] 

      The fragment is as follows:

       while ((ch = getchar()) != '\n')      {         putchar(ch++);         putchar(++ch);      } 
  7. How does C deal with different computer systems having different file and newline conventions?

  8. What potential problem do you face when intermixing numeric input with character input on a buffered system?

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