Sams Teach Yourself C in 21 Days

(singke) #1

  1. Using the ASCII chart in Appendix A, translate the following numeric values to
    their equivalent characters:
    a. 73
    b. 32
    c. 99
    d. 97
    e. 110
    f. 0
    g. 2

  2. How many bytes of storage are allocated for each of the following variables?
    (Assume that a character is one byte.)
    a.char *str1 = { “String 1” };
    b.char str2[] = { “String 2” };
    c.char string3;
    d.char str4[20] = { “This is String 4” };
    e.char str5[20];

  3. Using the following declaration:
    char string = “A string!”;
    What are the values of the following?
    a.string[0]
    b.
    string
    c.string[9]
    d.string[33]
    e.*string+8
    f.string


Exercises ........................................................................................................


  1. Write a line of code that declares a type charvariable named letter, and initialize
    it to the character $.

  2. Write a line of code that declares an array of type char, and initialize it to the
    string“Pointers are fun!”Make the array just large enough to hold the string.

  3. Write a line of code that allocates storage for the string “Pointers are fun!”, as in
    exercise 2, but without using an array.


246 Day 10

17 448201x-CH10 8/13/02 11:17 AM Page 246

Free download pdf