Section 2c

Step One


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Systematic and Structured Programming

Step One - Simple Action Statements

The Problem to Be Solved

The beginning of the process is to identify the problem and try to elicit all the important actions that your program is required to do. Here is an example program specification:

  1. The program solves for the roots of a quadratic equation

  2. For the following equation, it prompts the user for, and acquires, the x2 coefficient (A), the x coefficient (B), and the constant coefficient (C), for the following equation:

  3. Ax2 + Bx + C = 0

  4. Finally, the program provides the roots of the equation to the user as a displayed output. The first step is to identify the main parts of the program and write them in as comments. This program will only require a few simple statements. The following statements are provided with explanations, and then the code itself is provided.

Initialize the program

Get the coefficients from the user

Process the quadratic roots

Display the roots

End the program

The main function code for step 1 would look like the following:

int main()
{
// initialize program

// get coefficients from user

// process quadratic roots

// display results

// end program

return 0;
}

The program would be set up as follows:

#include <stdio.h>

int main()
{
// initialize program

// get coefficients from user

// process quadratic roots

// display results

// end program

return 0;
}

As you may notice, it wouldn't take more than a few minutes to write this, and while it may seem trivial, it is very important because you now have a feeling for how the program will flow. Even more importantly, you have broken the program down into smaller, more manageable problems.

Some notes:


To see the step one process in action, watch this video; then develop your step one code with or without the video as needed in your own enviroment.