Expert Answers

1. Since data stored in _____ is lost when the computer’s power is turned off, that type of memory is considered to be _____.
RAM, volatile
auxiliary storage, volatile
RAM, nonvolatile
auxiliary storage, nonvolatile
2. Set a variable to a value with the symbol _____, and test equality with _____.
=, =
==, ==
==, =
=, ==

3. A proper operator precedence, from first to last, is _____.
addition, subtraction, and multiplication
exponentiation, addition, and division
exponentiation, division, and multiplication
exponentiation, division, and subtraction
subtraction, addition, and multiplication
4. A computer uses ____ numerals to represent and manipulate data.
two
eight
10
16

5. The _____ structure is a _____ loop, meaning that its conditional expression is tested after the statements inside its body execute.
do-while, posttest
do-while, pretest
while, posttest
while, pretest

6. Which of the following is a type of C# error that results from invalid use of programming language rules?
Compiler error
Logic error
Runtime error
Syntax error

7. A home improvement store is giving a discount of 20% on all purchases of more than $250. Which of the following is the appropriate structure to use to program the statement?
Loop
Method
Decision
Sequence

8. The following C# code _____ compile. It contains a _____ error.
int x = 3 y = 2;
if (x < y)
Console.WriteLine(“x is less than y”);
will, syntax
will, logical
will not, syntax
will not, logical

9. A block of statements within the body of a WHILE loop must be surrounded with _____.
curly braces {}
parentheses ()
square brackets []
None of the above

10. Which data types do not include decimal places?
Int, float
Int, double
Int, decimal
Int, char

1. (TCO 3) Show the source code for a C# console application named “Sibs” that prints your first and last names on the first line, and the number of siblings you have on the second line.
· Declare and initialize an appropriate variable for your number of siblings.
· Include at least three descriptive comments.
State how you would use the error list window to identify and correct errors in your code. (Points : 20)

2. (TCO 5) Describe two types of loops that can be used to write the C# code required to print every second integer from 0 to 200 (i.e., 0, 2, 4, 6, etc.), each on its own line. Which would be a better choice and why? Write the code using that type of loop. (Points : 20)

3. (TCO 8) Briefly describe how parameter passing by value and by reference are accomplished in memory.
Write statement 1 to call Method A below. Write statement 2 to call Method B.
Which method uses pass by value? Which method uses pass by reference?
. (TCO 2) Although the following code compiles and runs, the programmer broke some major readability rules. Describe at least three changes that would make it easier for other programmers to read and understand the code.
class Program
{
static void Main() //main
{
int a;
int Floater = 10; // ints
for(int i = 0;i < Floater;i++) /* loop */{
a=function(i);
Console.WriteLine(a);
}
Console.Read(); //read
}
public static int function(int a) /*function*/ {
return (int)(Math.Pow((double)a,2.0));
}
}
(Points : 20)

6. (TCO 11) Write a C# program to store an array of these integers: 3, 45, 65, 74, and 33. Use an appropriate loop to multiply all of the values in the list. Print out the result.