| Message |
Post subject: switch case Posted: Thu Jul 23, 2009 11:32 pm |
|
|
Switch case statements are a substitute for long if statements that compare a variable to several "integral" values ("integral" values are simply values that can be expressed as an integer, such as the value of a char). The basic format for using switch case is outlined below. The value of the variable given into switch is compared to the value following each of the cases, and when one value matches the value of the variable, ...
Read more : switch case | Views : 46 | Replies : 0
|
|
| Top |
 |
Post subject: Functions Posted: Thu Jul 23, 2009 11:31 pm |
|
|
Now that you should have learned about variables, loops, and conditional statements it is time to learn about functions. You should have an idea of their uses as we have already used them and defined one in the guise of main. Getchar is another example of a function. In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive. You can either use the built-in library functions or ...
Read more : Functions | Views : 12 | Replies : 0
|
|
| Top |
 |
Post subject: If statements Posted: Thu Jul 23, 2009 11:29 pm |
|
|
If statements
The ability to control the flow of your program, letting it make decisions on what code to execute, is valuable to the programmer . The if statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false. One of the important functions of the if statement is that it allows the program to select an action based upon the ...
Read more : If statements | Views : 16 | Replies : 0
|
|
| Top |
 |
Post subject: Programming tricks Posted: Thu Jul 23, 2009 11:26 pm |
|
|
Back on the Z80 chip, if you wanted to load zero into a register, you XOR'd the register with itself. It gave the right answer, the ones became zeros and the zeros stayed zeros. But why do it in this obscure way, when there was a "move" 0 to the register? The answer is that it only took one byte of memory, and it was faster. If your program had to do it a million ...
Read more : Programming tricks | Views : 17 | Replies : 0
|
|
| Top |
 |
|
Last 10 active topics
|