Home > Articles > Programming > C#

  • Print
  • + Share This
This chapter is from the book

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 in Appendix A, "Answers."

Quiz

1. What are the by value data types available in C#?

2. What is the difference between a signed and unsigned variable?

3. What is the smallest data type you can use to store the number 55?

4. What is the biggest number that a type short variable can hold?

5. What numeric value is the character B?

6. How many bits in a byte?

7. What literal values can be assigned to a Boolean variable?

8. Name three of the reference data types.

9. Which floating-point data type has the best precision?

10. What .NET data type is equivalent to the C# int data type?

Exercises

  1. Change the range of values in Listing 3.6 to print the lowercase letters.

  2. Write the line of code that declares a variable named xyz of type float and assign the value of 123.456 to it.

  3. Which of the following variable names are valid?

    1. X
    2. PI
    3. 12months
    4. sizeof
    5. nine
  4. BUG BUSTER: The following program has a problem. Enter it in your editor and compile it. Which lines generate error messages?

     1: //Bug Buster
     2: //--------------------------------------------------------------
     3: using System;
     4: 
     5: class variables
     6: {
     7: public static void Main()
     8: {
     9:  double my_double;
    10:  decimal my_decimal;
    11: 
    12:  my_double = 3.14;
    13:  my_decimal = 3.14;
    14: 
    15:  Console.WriteLine("\nMy Double: {0}", my_double);
    16:  Console.WriteLine("\nMy Decimal: {0}", my_decimal);
    17: 
    18: }
    19: }
  5. ON YOUR OWN: Write a program that declares two variables of each data type and assigns the values 10 and 1.879 to each variable.

  • + Share This
  • 🔖 Save To Your Account