Exercises : Answer the following Question

Submitted by Anonymous (not verified) on Sun, 03/10/2013 - 21:00

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson. The answers and hints to the questions and exercises are given in Appendix E, "Answers to Quiz Questions and Exercises."
Quiz

    What are the values represented by the following enum names?

    enum months { Jan, Feb, Mar, Apr,
                  May, Jun, Jul, Aug,
                  Sep, Oct, Nov, Dec };

    What are the values represented by the following enum names?

    enum tag { name1,
               name2 = 10,
               name3,
               name4 };

    Which statements in the following are equivalent in the variable declaration?
        typedef long int BYTE32; BYTE32 x, y, z;
        typedef char *STRING[16]; STRING str1, str2, str3;
        long int x, y, z;
        char *str1[16], *str2[16], *str3[16];
    Can you pass some command-line arguments to a main() function that has the following definition?

    int main(void)
    {
       . . .
    }

Exercises

    Write a program to print out the values represented by the enumerated names declared in Quiz question 2.
    Given the following declarations:

    typedef char WORD;
    typedef int SHORT;
    typedef long LONG;
    typedef float FLOAT;
    typedef double DFLOAT;

    write a program to measure the sizes of the synonyms to the data types.

    Rewrite the program in Listing 18.4. This time, add integers starting at the value of MIN_NUM instead of the value of MAX_NUM.
    Write a program that accepts command-line arguments. If the number of command-line arguments, not including the name of the executable itself, is less than two, print out the usage format of the program and ask the user to reenter the command-line arguments. Otherwise, display all command-line arguments entered by the user.

Related Items

The goto Statement

The goto Statement

The continue Statement

The continue Statement

The break Statement

The break Statement

You can add a break statement at the end of the statement list following every case label, if you want to exit the switch construct after the statements within a selected case are executed.

The switch Statement

The switch Statement

Nested if Statements

Nested if Statements

As you saw in the previous sections, one if statement enables a program to make one decision. In many cases, a program has to make a series of decisions. To enable it to do so, you can use nested if statements.