Variables are the building blocks of development and while they are just as important to development as they are algebra we aren’t going to be doing any math here!
Understanding variables and their use in programming is important when learning programming on your own.
Most people have encountered the concept of variables at some point in their life whether you’re plotting a line , measuring geometric shapes or doing complex math problems variables are what allow us to take the means for solving something specific and apply it to a more general application of the problem!
Just like we use variables in describing how to measure the area of a rectangle we can use variables in programming to substitute values that might vary over time.
Ok now that we have some idea of what variable are lets talk in general about the common ones.
Character – this is a single letter or number.
A string is a series of characters. This could be anything from a couple characters in a row to a whole paragraph of text.
A Boolean or “bool” is a true or false, Sometimes these are represented as the words “true” or ” “false” or even 0 or 1.
An Int or Integer is whole number either positive or negative but not containing a decimal value.
A double is a number just like an int except it does allow a decimal.
Now that we know a little bit about the types of variables lets talk a little about how you might use them.
Let’s say we have a basic hello world application. (for newcomers typically when you start a new language the first program you build is a hello world program, this is simply a program that prints out the text “Hello world”) In my mind one of the best ways to learn a new language or how to program in general is to start with a basic program , get that working , and then when you have it working extend the functionality of that app and keep extending it as far as you can.
So in that spirit let’s take a basic hello world app and extend it using a variable to instead say hello to a specific person..