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
What's the difference between an integer variable and a floating-point variable?
Give two reasons for using a double-precision floating-point variable (type double) instead of a single-precision floating-point variable (type float).
What are five rules that the you know are always true when allocating size for variables?
What are the two advantages of using a symbolic constant instead of a literal constant?
Show two methods for defining a symbolic constant named MAXIMUM that has a value of 100.
What characters are allowed in C variable names?
What guidelines should you follow in creating names for variables and constants?
What's the difference between a symbolic and a literal constant?
What's the minimum value that a type int variable can hold?
Exercises
-
In what variable type would you best store the following values?
-
A person's age to the nearest year.
-
A person's weight in pounds.
-
The radius of a circle.
-
Your annual salary.
-
The cost of an item.
-
The highest grade on a test (assume it is always 100).
-
The temperature.
-
A person's net worth.
-
The distance to a star in miles.
-
-
Determine appropriate variable names for the values in exercise 1.
-
Write declarations for the variables in exercise 2.
-
Which of the following variable names are valid?
-
123variable
-
x
-
total_score
-
Weight_in_#s
-
one
-
gross-cost
-
RADIUS
-
Radius
-
radius
-
this_is_a_variable_to_hold_the_width_of_a_box
-