Manipulating Values in Your Programs

• 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. Try to understand the quiz and exercise answers before continuing to the next day's lesson. Answers are provided on the CD.

Quiz

The following quiz questions will help verify your understanding of today's lessons.

1. What character is used for multiplication?

2. What is the result of 10 % 3?

3. What is the result of 10 + 3 * 2?

4. What are the conditional operators?

5. What C# keyword can be used to change the flow of a program?

6. What is the difference between a unary operator and a binary operator?

7. What is the difference between an explicit data type conversion and an implicit conversion?

8. Is it possible to convert from a long to an integer?

9. What are the possible results of a conditional operation?

10. What do the shift operators do?

Exercises

Please note that answers will not be provided for all exercises. The exercises will help you apply what you have learned in today's lessons.

1. What is the result of the following operation?

2. 2 + 6 * 3 + 5 – 2 * 4

3. What is the result of the following operation?

4. 4 * (8 – 3 * 2) * (0 + 1) / 2

5. Write a program that checks to see whether a variable is greater than 65. If the value is greater than 65, print the statement "The value is greater than 65!".

6. Write a program that checks to see whether a character contains the value of t or T.

7. Write the line of code to convert a long called MyLong to a short called MyShort.

8. Bug Buster: The following program has a problem. Enter it in your editor and compile it. Which lines generate error messages? What is the error?

9. ``` 1: class exercise
2: {
3:   public static void Main()
4:   {
5:    int value = 1;
6:
7:    if ( value > 100 );
8:    {
9:      System.Console.WriteLine("Number is greater than 100");
10:    }
11:   }
12: }```
10. Write the line of code to convert an integer, IntVal, to a short, ShortVal.

11. Write the line of code to convert a decimal, DecVal, to a long, LongVal.

12. Write the line of code to convert an integer, ch, to a character, charVal.

• + Share This
• 🔖 Save To Your Account