|
by David Hamrick |
||
| Home Links Starting Out Variables Projects
|
Int, Char, Float Variables are vital to programming. In a nutshell a variable is a value. Lets go through the 3 basics. Int - int is a reduced way of saying an integer.
Which is a whole number between -32768 to 32767. Lets go straight into an example. Its easiest to understand just by seeing. #include <stdio.h> char cd, cf; //Declared 2 char
variables cd and cf I think all of that is pretty self explanatory. When you declare a variable you can give it a value right away or wait awhile to give it one. But be warned if you try to do anything to that number before its given a value you will get a wierd number. You can also declare more than one variable at the same time as we saw in the char cd, cf; line. They are 2 completely different variables that have nothing to do with eachother except they are both char variables. Now that we are done declaring variables inside of functions lets try doing it outside of a function #include <stdio.h> int d;
|