C Programming
Essay by review • February 20, 2011 • Essay • 327 Words (2 Pages) • 1,284 Views
The best way to approach a C language problem is to consider it in three major stages:
1. Problem analysis and program design - about one-half the total time;
2. Writing the program itself - about one-quarter of the total time;
3. Testing and debugging - the time remaining, about one-quarter of the total.
Most students tend to skimp on the first part and merge the other two into an unending sequence of "try this" and "try that", until something happens to work. Sometimes it’s not really understood why it finally works (if it really does)!
The solution is to use tools like pseudocode to sort out how to actually write the program.
Analyze the problem
This may sound easy, but it’s the part most often neglected. Read over the lab carefully. Now read it again. Read it a third time, and try to write out (on a separate piece of paper, or using a tool like Word) an outline of what you believe is required. From that, list items you are unclear on, or parts that appear contradictory. Now read the lab and your notes again, making corrections as you go. Consult with the person next to you, your SO, your mother, or (often a last resort) even the lab instructor. Repeat this until you are certain that you understand the entire problem.
Prototypes
Identify the awkward parts of the problem, areas you might not be sure how to code, things that are new to you, or issues central to solving the lab. Now write a prototype program, a small C program that you will discard when you are done with it. Run the prototype as often as necessary, using the debug tools to trace your way through the code, watching key variables change as you do so.
Yes, you should use pseudocode or another software engineering tool to help you write each prototype. Once you have tested all the prototype programs you believe you will need to address the lab, move on to program design.
...
...