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 if-else Statement

The if-else Statement

The if statement

The if statement

If life were a straight line, it would be very boring. The same thing is true for programming. It would be too dull if the statements in your program could only be executed in the order in which they appear.

Mathematical Functions in C

Mathematical Functions in C

Basically, the math functions provided by the C language can be classified into three groups:

    Trigonometric and hyperbolic functions, such as acos(), cos(), and cosh().

Changing Data Sizes

Changing Data Sizes

Enabling or Disabling the Sign Bit

Enabling or Disabling the Sign Bit

As you know, it's very easy to express a negative number in decimal. All you need to do is put a minus sign in front of the absolute value of the number. But how does the computer represent a negative number in the binary format?