A flowchart is a graphical representation of the various steps involved in an algorithm. It makes the flow of the program easy to understand. A flowchart uses different symbols to indicate different operations.
The various symbols used in a flowchart are shown in Fig.IP-1.6;
The symbols shown in Fig.IP-1.6 and the operations they represent are explained as follows:
⦁ Terminal: Indicates the start or end point of a program. A terminal has elliptical shape.
⦁ Input/output box: Accepts data or displays the results. An input or output box is represented by a parallelogram.
⦁ Processing box: Write the data that needs to be processed. A processing box is represented by a rectangle.
⦁ Data-flow lines: Indicates the direction of data flow. The data flow lines are represented by arrows.
⦁ Decision box: Tests a condition, which results a true value or a false value. A decision box is represented by a diamond shape.
Fig.IP-1.7 shows the flowchart for our program that displays registration information of the students of an educational institute:
Coding the Solution
The third stage is coding the solution or writing the program, based on the flowchart and pseudocode. First thing that you must ensure prior to writing a code is that the appropriate software is installed on the computer. For example, a C++ compiler, such as Borderland C++ or Turbo C++ should be installed on the computer if you want to write a program in the C++ language. Software used for programming may consists of one or more of the following tools:
⦁ Code Editor: Provides you an editor where you can write the business logic (source code) of an application (program). A code editor is optimized for programming. For example, in a code editor, executable statements might appear in one color and comments in another color to make the program easy to understand.
⦁ Compiler (or interpreter): Converts the code in each source code file into machine language code and places it in a file, known as object file.
⦁ Linker: Combines all the object files into an executable program that can run directly on the target computer.
⦁ Debugger: Helps us in finding errors in the programs.
Writing and executing a program is accomplished by performing the following steps:
1. Type the program.
2. Compile the program.
3. If there are any compile-time errors, correct them and again compile the program.
4. Run the program to obtain the desired results.
5. If there are any run-time errors, check the logic of the program and continue from Step 2
In most of the programming languages, the compilation and execution of a program take place in a single step.
Compilers can only detect syntax errors. The errors that are detected as run-time are known as run-time errors. It is important to know the difference between compile-time and run-time errors.
⦁ Compile-time error: Occurs if there is a mistake in the syntax of the program. A program will not compile successfully if there are syntax errors (or compile-time errors).
⦁ Run-time error: Occurs if there s a mistake in the logic of the program. A program that was compiled successfully may have run-time errors. Run-time errors occur when you run the program.
Testing the Program
Testing is the last stage in the program development cycle. Once you have developed a program, you should test it to ensure that it is free of bugs (errors) and is capable of solving the given problem. Sometimes, it is possible that a program does not show any compile-time or run-time error but still fails to give the desired output. In such cases, you should test the program with the help of a set of input values and review all the stages of program development cycle to find out what went wrong.