Chapter 3
C# Programming: From Problem Analysis to Program Design · 17 exercises
Problem 3
Which of the following is a reference type? a. int b. bool c. string d. decimal e. integral
7 step solution
Problem 4
e. all of the above # The character that cannot be used with an identifier is: a. – b. $ c. * d. # e. all of the above
4 step solution
Problem 5
Which of the following is a reserved keyword? a. Console b. Out \(c .\) int d. System e. all of the above
3 step solution
Problem 6
One of primary differences between float, double, and decimal is: a. float is used to represent more significant digits. b. double is normally used with large monetary values. c. decimal is not used to display negative values. d. double does not require suffixing a numeric literal with a value such as m or \(\mathrm{f}\). e. decimal is primarily used to represent small monetary values that require a $\$$ for formatting.
10 step solution
Problem 7
Which of the following is a valid declaration for a variable to store the name of this textbook? a. string name of book; b. char nameOfBook; c. boolean nameOfBook; d. string bookName; e. char book Name;
3 step solution
Problem 8
using: a. classes b. types c. objects d. namespaces e. programs # Types are implemented in C# using: a. classes b. types c. objects d. namespaces e. programs
3 step solution
Problem 9
An object of the int class is: a. 47.98 b. 47 c. int class d. type object e. type integral
2 step solution
Problem 11
Adding the keyword const to a declaration: a. places a value in memory that cannot be changed b. declares variables of the constant type c. must be done by placing it after the identifier in the declaration d. can only be done with the integral types e. is prohibited in \(\mathrm{CH}\)
4 step solution
Problem 12
Which statement increases the result by \(15 ?\) a. \(15+=\) result; b. \(15=+\) result; c. result \(=+15\) d. result \(+=15\) e. result \(=15+\)
8 step solution
Problem 13
What is stored in ans as a result of the arithmetic expression, given the following declarations? int ans \(=0, \mathrm{v} 1=10, \mathrm{v} 2=19\) ans \(=--v 2 \% v 1++\) a. 1.8 b. 9 c. 8 d. 2 e. none of the above
5 step solution
Problem 14
What is stored in ans as a result of the arithmetic expression, given the following declarations? int ans \(=10, \mathrm{v} 1=5, \mathrm{v} 2=7, \mathrm{v} 3=18\) ans \(+=\mathrm{v} 1+10^{*}(\mathrm{v} 2--/ 5)+\mathrm{v} 3 / \mathrm{v} 2\) a. 18 b. 32 c. 28 d. 30 e. none of the above
7 step solution
Problem 17
1 c. the first value d. \(_{\text {value } 1}\) e. AVALUE # Which of the following are valid identifiers? If they are invalid, indicate why. a. intValue b. value#1 c. the first value d. \(_{\text {value } 1}\) e. AVALUE
6 step solution
Problem 18
For each of the following, declare a variable using the best choice for data type. a. a counter for the number of correct responses b. the amount of money you owe on a credit card c. the name of your hometown d. the grade you hope to obtain on the next exam e. the grade you hope is recorded at the end of the term for this course
5 step solution
Problem 19
For each of the following declarations, write an appropriate compile-time initialization. a. counter for the number of correct responses begins with zero b. amount of money you owe on a credit card is zero c. name of the hometown is the city where your school is located d. grade on the next exam is 100 e. grade to be recorded at the end of the term for this course is an \(A\).
5 step solution
Problem 20
Suppose \(x, y,\) and \(z\) are int variables and \(x=2, y=6,\) and \(z=10 .\) What will be in the memory locations of each of the variables after each of the following statements is executed? (For each exercise, use the original declaration.) a. \(z+=++y \% 2\) b. \(x=y+14-z / 7\) c. \(x=y^{*} z / 2-x^{*} z\) d. \(x \%=-x-y^{*} 2\) e. \(y=(z-y)^{*} 2+-y\)
5 step solution
Problem 23
Explain how a variable differs from a constant.
4 step solution
Problem 24
Explain how type, class, and object are related to a string.
5 step solution