Review Questions

I l @ ve RuBoard

Review Questions

  1. Which data type would you use for each of the following kinds of data?

    1. The population of Rio Frito.

    2. The average weight of a Rembrandt painting.

    3. The most common letter in this chapter.

    4. The number of times that the letter occurs in this chapter.

  2. Why would you use a type long variable instead of type int ?

  3. Identify the type and meaning, if any, of each of the following constants:

    1. '\b'

    2. 1066

    3. 99.44

    4. 0XAA

    5. 2.0e30

  4. Virgila Ann Xenopod has concocted an error-laden program. Help her find the mistakes.

     include <stdio.h> main (  float g; h;  float tax, rate;  g = e21;  tax = rate*g; ) 
  5. Identify the data type (as used in declaration statements) and the printf() format specifier for each of the following constants:

    Constant Type Specifier
    a. 12    
    b. 0X3    
    c. `C'    
    d. 2.34E07    
    e. `\040 '    
    f. 7.0    
    g. 6L    
    h. 6.0f    
  6. Identify the data type (as used in declaration statements) and the printf() format specifier for each of the following constants (assume a 16-bit int ):

    Constant Type Specifier
    a. 012    
    b. 2.9e05L    
    c. `s'    
    d. 100000    
    e. `\n'    
    f. 20.0f    
    g. 0x44    
  7. Suppose a program begins with these declarations:

     int imate = 2; long shot = 53456; char grade = `A'; float log = 2.71828; 

    Fill in the proper type specifiers in the following printf() statements:

     printf("The odds against the %__ were %__ to 1.\n", imate, shot); printf("A score of %__ is not an %__ grade.\n", log, grade); 
  8. Suppose that ch is a type char variable. Show how to assign the carriage -return character to ch by using an escape sequence, a decimal value, an octal character constant, and a hex character constant. (Assume ASCII code values.)

  9. Correct this silly program. (The / in C means division.)

     void main(int) / this program is perfect / {  cows, legs integer;  printf("How many cow legs did you count?\n);  scanf("%c", legs);  cows = legs / 4;  printf("That implies there are %f cows.\n", cows) } 
  10. Identify what each of the following escape sequences represents:

    1. \n

    2. \\

    3. \"

    4. \t

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