Beginning Programming For Dummies
If you’re just beginning to write computer programs, follow these helpful guidelines to create an effective program. Know the common loop structures, branching structures, and mathematical operator symbols to make your program perform specific instructions.
Tips for Writing Computer Programs
When you’re ready to write a computer program, keep these how-to tips on programming in mind so the program you create has clear instructions for the computer to carry out tasks effectively:
Use descriptive variable names.
Use appropriate data types.
Write programs that are easy to read and understand.
Use simple algorithms and data structures whenever possible.
Comment your program liberally. (Or, as an alternative, make your code so clear and easy to read that you don’t need comments in the first place.)
Write modular programs by dividing a large program into several smaller programs that you isolate from one another.
Test boundary conditions by giving your program extremely high and extremely low numbers.
Choose the right algorithm and data structure for your program.
Eliminate all unnecessary instructions or variables.
Make your program work first; then worry about optimizing the program to make it smaller and faster. Remember that a slow, bloated program that works is preferable to a small, fast program that doesn’t work.
Common Computer Programming Loop Structures
Looping instructions, one of the basic logic structures in computer programming, tell the computer to repeat one or more instructions. Check out this list of basic loop structures in various computer programs and languages:
Common Branching Structures in Computer Programming
Branching structures make your computer programs run different instructions depending on the value of specific data. Branching structures, like the ones listed below, allow your computer to run more effectively by accepting and reacting to outside data.
Common Mathematical Operators Used in Programming
In computer programming, four basic ways are used to manipulate numbers: adding, subtracting, multiplying, and dividing. To perform a mathematical operation with two numbers (or two numbers represented by variables), use these symbols in your computer program:
|Mathematical Operation||Symbol to Use|
|Division||/ (forward slash)|
|Integer division||\ (backward slash)|