Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

Workshop

The Workshop provides quiz questions to help you solidify your understanding of the material covered and exercises to provide you with experience in using what you've learned.

Quiz

  1. What's the difference between an integer variable and a floating-point variable?

  2. Give two reasons for using a double-precision floating-point variable (type double) instead of a single-precision floating-point variable (type float).

  3. What are five rules that the you know are always true when allocating size for variables?

  4. What are the two advantages of using a symbolic constant instead of a literal constant?

  5. Show two methods for defining a symbolic constant named MAXIMUM that has a value of 100.

  6. What characters are allowed in C variable names?

  7. What guidelines should you follow in creating names for variables and constants?

  8. What's the difference between a symbolic and a literal constant?

  9. What's the minimum value that a type int variable can hold?

Exercises

  1. In what variable type would you best store the following values?

    1. A person's age to the nearest year.

    2. A person's weight in pounds.

    3. The radius of a circle.

    4. Your annual salary.

    5. The cost of an item.

    6. The highest grade on a test (assume it is always 100).

    7. The temperature.

    8. A person's net worth.

    9. The distance to a star in miles.

  2. Determine appropriate variable names for the values in exercise 1.

  3. Write declarations for the variables in exercise 2.

  4. Which of the following variable names are valid?

    1. 123variable

    2. x

    3. total_score

    4. Weight_in_#s

    5. one

    6. gross-cost

    7. RADIUS

    8. Radius

    9. radius

    10. this_is_a_variable_to_hold_the_width_of_a_box

  • + Share This
  • 🔖 Save To Your Account