- Displaying Basic Information
- Manipulating Variable Values with Operators
- Understanding Punctuators
- Moving Values with the Assignment Operator
- Working with Mathematical/Arithmetic Operators
- Making Comparisons with Relational Operators
- Understanding Logical Bitwise Operators
- Understanding the Type Operators
- Using the sizeof Operator
- Shortcutting with the Conditional Operator
- Understanding Operator Precedence
- Converting Data Types
- Understanding Operator Promotion
- Bonus Material: For Those Brave Enough
- Summary
- Q&A
- Workshop
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.
What character is used for multiplication?
What is the result of 10 % 3?
What is the result of 10 + 3 * 2?
What are the conditional operators?
What C# keyword can be used to change the flow of a program?
What is the difference between a unary operator and a binary operator?
What is the difference between an explicit data type conversion and an implicit conversion?
Is it possible to convert from a long to an integer?
What are the possible results of a conditional operation?
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.
-
What is the result of the following operation?
-
What is the result of the following operation?
-
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!".
-
Write a program that checks to see whether a character contains the value of t or T.
-
Write the line of code to convert a long called MyLong to a short called MyShort.
-
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?
-
Write the line of code to convert an integer, IntVal, to a short, ShortVal.
-
Write the line of code to convert a decimal, DecVal, to a long, LongVal.
-
Write the line of code to convert an integer, ch, to a character, charVal.
2 + 6 * 3 + 5 2 * 4
4 * (8 3 * 2) * (0 + 1) / 2
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: }