This is where you will learn about variables and how to declare and initialize them

A variable is an item that the program will store in the computer's RAM (Random Access Memory), so that the program can continue to refer to the variables.

There are 4 types of variables that I will tell you about. These are:

We will start out with boolean variables:

A boolean variable can only store two values-true or false. For example in a video game you can use a boolean variable called isDead to keep track of whether the player was killed or not.

This is how to declare a boolean variable:

before using the variable you have to declare it by typing it in to your code. This means you will be reserving space in the memory to keep track of the variable. This is what to type: Boolean blnVar;

This is how you will initialize it, initializing means you are setting the value of the variable for the first time. This line of code will initialize it: Type blnVar = true; into another line of code.

Second we will learn about integers:

An integer is used when you are trying to keep track of numbers, like counting. Only use integers if you do not need decimal values. Integers are like: ...-1,0,1... This is how to declare an integer value, type this into your program code: Int32 intVar;

This is how you will initialize that vaule, type this into your program code:intVar = -47; The -47 is the variable that I chose to use, you can use any other whole number.

Third we will go over the floating point variables (decimal and double):

When dealing with fractions, use decimals. The most common floating point variable is Double; this stands for Double precision floating-point number. Just remember to be careful when using decimals, as they aren't as precise. These values are like: 4.17,3.14,etc... This is how to declare a floating point variable, type this into your program code: Double dblVar;

This is how you will initialize that vaule, type this into your program code: dblVar = 3.14;The 3.14 is the variable that I chose, you can use any other decimal number.

Lastly, we will learn about string variables:

If you are going to represent words, a string variable is what you should use. A string variable can be any letters or punctuation you like. This is how to declare a string variable, type this into your program code: String strVar;

This is how to initialize a string variable, type this into your program code:str = "hi";

Most times you can just initialize the variable right after you declare it like this: String strVar = "hi";

JUST KEEP IN MIND THAT YOU HAVE TO DECLARE A VARIABLE BEFORE YOU INITIALIZE IT. Here is an example of declaring variables in a program: The first step as always is to open visual studio, this time we will be using a Console Application, go ahead and select it (remember to name it). This program will simply just calculate the price of an item. Lets just go over what's happening here:
  • The first star is an example of both integers and floating point variables, here we are telling the computer we are going to use integers and the integer is going to represent age. Next we declare the Double because our price is a decimal number, once we declare our decimal we will just do a little equation; this equation will calculate our price after taxes ($1.13 in taxes we'll say.) After this we are just initializing the age variable saying that we are 16 years old.
  • The second star is an example of a string variable, we are telling the computer to say what is in the quotations plus our age that we entered in earlier, next it is again saying what our total is by taking the little equation with the price and calculating the total, this will just show the total not the whole calculation. The ($0.00) is just to let the computer know that we only want 3 numbers as it is a price.
  • Lastly, here is our Console.ReadLine, this is just making the program stay open.