Variables!

On this page you will be learning how to declare and intialize variables!

Boolean Variables

This variable has only two outcomes. True, or False. Usually this variable could be used in gaming when a character dies. It is the basic kind of variable to use because it is very easy to under stand. This is what a boolean Varibale looks like in Visual Studios. What you have to do is write Boolean = blnName; so what this does is naming the boolean that you are using for the program this is called declaring. blnName = true; what this does is intializing what the variable is going to be.

Integers Variables

For the intergers Variable is some what like the Boolean variable when it comes to declaring and intializing. You write Int 32 = intName; This is declaring your variable and intName = 27; is intializing the variable. Integers Variables are only dealing with whole numbers. so -2,-5, 7, 24, 489, etc... Lots of programs use integer variables because it can do the math for you.

Decimal Numbers

For decimal numbers it is like the integers except it is dealing with decimal or fraction. These numbers are called floating points. What we do is use double. double means Double precisions floating-point number. to declare a floating point it is used like this: double = dblName; and to intialize it you do dblName = 24.7. Easy right?

In the end of the program you used the name of the variable (ie: blnName,intName, or dblName) in the code you need it forand it will use it correctly for your program.

Strings

For Strings it is like a variable, but instead of using numbers, you can use words. The same process goes with declaring and intializing a string. String = strName; to declare and strname = "Hi"; to intialize. BUT! For strings it could be done in one sentence, unlike the number variables. You could do it like this: String strName = "Hi"; You could use strings to allow the program to remember words and add them to other sentences during the program.