Workshop






Workshop

Quiz

1.

What data type would you use to hold currency values?

2.

Which data type can be used to hold any kind of data and essentially serves as a generic data type?

3.

What can you create to eliminate magic numbers by defining a literal value in one place?

4.

What type of data element can you create in code that can have its value changed as many times as necessary?

5.

What are the first and last indexes of an array dimensioned using string_strMyArray[5]?

6.

What word is given to describe the visibility of a constant or variable?

7.

In general, is it best to limit the scope of a variable or to use the widest scope possible?

Answers

1.

The decimal data type.

2.

The object data type.

3.

Constants are used to eliminate magic numbers.

4.

Variables can have their values changed as often as necessary, within their scope.

5.

The first index is 0, and the last index is 4.

6.

Scope describes the visibility of a constant, variable, or procedure.

7.

It is best to use the narrowest scope possible.

Exercises

1.

Create a project with a text box, button, and label control. When the user clicks the button, move the contents of the text box to a variable and then move the contents of the variable to the Text property of the label. (Hint: A string variable will do the trick.)

2.

Rewrite the following code so that a single array variable is used rather than two standard variables. (Hint: Do not use a multidimensional array.)

string strGameTitleOne;
string strGameTitleTwo;
strGameTitleOne = "Quake 4";
strGameTitleTwo = "Call of Duty 2";



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows