|
The Toronto Maple Leafs have 38 wins. They have 25 losses. This gives them a winning percentage of 0.603 |
You can set the initial value of variables at the same time that you declare them. You do this by putting a colon equals followed by the value after the variable declaration on the same line. The previous program could be shortened like this:
|
|
You need to make sure that you assign the proper type of values to each variable. The following program has several errors. Each line with an error has a comment explaining the error.
|
You may be wondering why we've been using variables instead of constants. So far we haven't changed any of our so-called variables. Here is a program to prove that variables can vary:
|
10 Now number is 5432 And now it is -99 |
|