I have listed some sample program problem and their algorithmic solution illustrated with flowchart. I also have the source code that is generated from these flowchart by LogicCoder. The information here is available in pdf format along with actual flowchart files that you can use with LogicCoder.

What is a Computer Program Problem?


A computer is any device or machine which operation can be ordered under the control of a program to solve a specific problem. There are many different kinds of computing devices to be found at various points in human civilization and more recently, during the industrial revolution. By a computer program we mean the configuration of a device or machine that affects the way the device or machine operates or behaves under the influence of some input energy source. Therefore, there are permanently programmed systems such as those found in industrial machines and there are re-programmable devices most of which are electronic systems. I have given broad definitions to the terms "Computer" and "Computer Program" in preceding paragraph. However, in this manual we confine our interest to digital computer systems that operates on the principle of the stored program concept. Therefore, a more concise definition of a Computer Program is as follows.

A concise definition of a computer is as follows:
Any machine or device that will accept an input amount of data, process it under the control and direction of a program and then output the process result to some other device or medium. Hence, a computer is made out of the basic elements illustrated here.


Digital computers operates on the principles of the binary number system and are therefore controlled by digital signals. An example digital signal is illustrated in figure 1-3. Here are some of the basic elements that constitute a micro-computer system

A microcomputer system is made out of three basic functional elements:
1. Input and Output (I/O) ports
2. A Central Processing Unit (CPU) and
3. Main Memory

Each component of a microcomputer system can in turn be broken down into smaller sub-system components. For example, the CPU (or microprocessor) consists of the following sub-system components:
(1) A set of registers
(2) A control unit
(3) An arithmetic and logic unit (ALU).

The operations performed by a computer require data. Data values are represented as digital signals like that illustrated in figure 1-3. Data is the representation of facts, concepts, or instructions in a structured and logical manner suitable for processing, communication, and interpretation by humans or some programmed device. Examples of data are: The balance of a bank account, The score a student receive on a test, or The list of all male students doing a particular subject at a college. The purpose of a computer is to accept and process data to produce useful information for human use. In the context of a digital computer system, we define data as Information in a form that can be used by a computer program.

An Example Digital Signal
Example Digital signal

Therefore, we see that the signal represented in figure 1-3 could be that of the ASCII code for a keyboard character. It could even be that of a coded machine instruction been transmitted through the system or it could be the representation of some other data format been used by a program.


A computer program is a predetermine sequence of instructions that specify the operations to be done by a computer on data values. An instruction is a sequence of Binary Digits (bits) that can be used to control the internal electronics of a digital computer system. Therefore, instructions are machine codes that specify what operation is to be performed by the electronics of the computer system.

The "Stored Programming Concept" requires that both the data values and the instructions that controls operations on them during the run of a program to be represented in a digital format and be stored in the Internal memory of the computer system.


On a digital computer, programs at machine level consist of a series of binary words that are directly interpreted by the central processing unit (CPU). These specific sequences of instructions are designed to solve a particular problem on a selected device. Programming is the process of selecting the correct sequence of machine instructions to be used for solving a specific problem. The binary coded instructions used on a selected electronic device (computer system) are determine by the electronic configuration of the device. However, there are fundamental concepts and principles that govern the way programs are written and how they are executed. Writing machine programs require that you have knowledge of the electronic configuration of the machine. In addition, a program written for a given machine is not portable to other machines. Therefore, writing machine programs is best left to people who like to do things using 1's and 0's. The example below illustrates a machine level computer program.

Not many people will want to write programs for themselves using machine language. Therefore, manufacturers of microprocessors invented Assembly Language so that more users will purchase their product and at the same time "copy cat" users will have more problems trying to figure out the detail structure of their product.

Table 1-1. An example Machine/Assembly language program.
Example machine program

Assembly language is machine language written using mnemonics. A mnemonic is a word or combination of letters that suggest the meaning of the instruction it represents. Like BASIC, an assembly language consists of a set of commands that can be written into instructions that tells the computer what to do. However, each mnemonic word in an Assembly Language instruction set refers directly to the digital components of the computer system. Therefore, we see that Assembly Language mainly provides a convenient abstraction of the binary interpretation of a particular machine instruction set and the representation of data values on the system. Assembly Language does not adequately abstract the structure of a system.

From this we see that a programming language forms an interface between the programmer and the hardware system of the computer. There are levels of abstraction between the hardware system and the programming language. These abstractions are logical and are built on consistent rules that manifest themselves at the software interface as syntax and semantic rules in particular programming languages. Good programmers have a comprehensive knowledge of the way digital computer systems works and is able to appreciate the syntax and semantic rules in well defined programming languages. Understanding of a computer system includes basic knowledge of the way the hardware system works at machine or assembly language level.

Click the following link to purchase books with the above and following information with more detailed explanation. Click HERE More information about these books can be found at this link.


A digital computer system is design to execute instructions coded in a digital format. The set of instructions that the computer system is design to execute is called the machine instruction set for the system. Programming a computer system at machine level requires that the programmer is familiar with the instruction set of the machine and the physical architecture of the system. Therefore, as you can appreciate, people who are not expert in digital system are easily put off at this level.

Therefore, we had to invent a system whereby a person who is not an expert at this level can program such a digital device that will solve a problem for the programmer with the solution approach been in the programmer's problem domain as opposed to that of the implementation machine domain.

In a high level programming language instructions are written using statements and expressions similar to those used in every day natural languages. Instructions written in a low-level language are written using machine code or mnemonics. Low level languages are machine oriented. Because of the limitation of low level programming languages, high level languages were developed. High level languages are:
(a) Similar to English with the usage of words and symbols
(b) More user friendly than low level languages
(c) Problem oriented rather than machine oriented
(d) Shorter than their machine equivalent.
A single statement in a high level language can be translated into many machine instructions

Click the following link to get more information about the systematic approach to programming and the Program Development Life Cycle. Click HERE


Because program flowcharting is a visual system that helps you to separate the issues of a program language paradigm from those of the control logic in a program solution.

This section gives a concise introduction to the concepts and principles of flowcharting as a means for illustrating program algorithms to be executed on digital computer systems. This on-line documentation is not intended to be a detailed practical guide. Reference sources that gives more practical learning material including programming language concepts and design techniques are given at the link to additional learning resources. I will give you a link that gives you some experimental results from students learning programming with a visual design system as opposed to purely using a text base programming language.

The difference with UML is that it is base on high level concepts that are not well defined and does not deal with issues that have been bugging software engineers and computer programming for a long time now. Typical issues UML fail to deal with are the issue of Complexity, Maintainability and Re-usability. LogicCoder effectively deals with these issues by developing a standard for the design of program algorithms with the use of program flowchart. These are simple straight forward easy to understand principles. They are not targeted at the highly academic but they can be used by the highly creative person to build sound, large, complex and consistent systems.

Visual programming system that automates lots of programming tasks for the development of complex software systems is evolving and is becoming the predominant choice in all areas of program/software development.


In the following set of sample program problems and their solution, I illustrate the use of an automated code writing system, namely LogicCoder for the integration of problem solution design, system documentation, system coding and maintenance with the use of a single user document interface.

Problem specification
The sample program used in this chapter prepares a report on a checking account. The report is an output listing of checks drawn on a personal account in the month of September. Each line of the report list information on each check drawn during the month as follows. The amount drawn on each check, the check number, the check date and the person to whom the check is made payable. At the end of the report listing, the total number of checks and the total amount drawn on all checks for the month are printed on the output report.

The Problem Flowchart Solution

Sample program logic design

With LogicCoder, you can quickly and easily modify the control logic so that each record in the program is included as part of an internal data list. In addition, you can change the Input/Output symbols that "Read a Record" to appropriate Processing symbol so that the system implement the control loop as a for-next loop. You can also put these symbols into the Ignore state and then put an appropriate control for statement in the loop decision.

ANSI C source code generated by LogicCoder
void main(void)
r = 0; TotalChecks = 0;TotalAmount = 0;
printf("\n\nChecking Account report\t Date: %s", __DATE__);
scanf("%s,%f,%s",FileRec[r].Name, &FileRec[r].Amount, FileRec[r].Payee);
while(strcmp(NAME, "END OF FILE"))
TotalAmount += CheckFile[r].Amount;
printf("\n\t%s\t%.2f\t%s", FileRec[r].Name, FileRec[r].Amount, FileRec[r].Payee);
scanf("%s,%f,%s",FileRec[r].Name, &FileRec[r].Amount, FileRec[r].Payee);
printf("\n\n\tTotal number of checks %d", Totalchecks);
printf("\nTotalAmount of all checks: %s", TotalAmount);


Click the following link to download a sample free tutorial copy of LogicCoder with the source code text file for the following flowchart. Download is a zip file for Ms Windows. Click to download. When you have installed LogicCoder, load the flowchart below and then the source code text file. You can then generate the required C/C++ program. You can then do modifications to the flowchart to create other programs with similar control logic.

Problem Specification
A mileage report for sales people is to be prepared. The input test data is listed below. Each report line should contain the sales person's name, the beginning mileage, the ending mileage, the total mileage done (ending mileage - beginning mileage), and the mileage allowance. The mileage allowance is calculated by multiplying the total mileage by 0.20. The total number of sales persons, the total mileage done by all sales persons, and the total mileage allowance for all sales persons is to be printed at the end of the listing. The output listing should contain report and column headings.

Problem Flowchart Solution
Flowchart for Mileage report
A sample copy of input test data is given in the table below. The input test data is to be included as part of the source code.





Our next sample program problem illustrate the basic elements in the control logic of the of the Case structure and its implementation within the loop logic structure.You can also have control logic for a loop nested on either legs of the Case logic structure.

The case structure can also have multiple instructions on either or both path that is given control after the decision instruction is executed. Figure 4-3 illustrates an example of this.

Problem Specification
A traffic citation report is to be prepared. You are required to design and code a program that will produce the report. INPUT DATA FILE The input test data file consists of records. Each record contain the name of the person receiving the traffic citation, a code that indicate whether the citation is for moving (code M) or for non-moving (code N) violation, and the number of citation for that person over the pass three years. The input test data is given in the table below.

Problem Flowchart Solution
Program logic flowchart

Each line on the output report list the name of the person receiving the traffic citation, a fine of 30.00 for moving violation or 10.00 for non-moving violation, a penalty of 20.00 if the number of violation is more than 3 and no penalty if the number of violation is less than or equal to 3. Each line on the report should also list the total fine due (fine + penalty). The total number of tickets, the total moving violation, the total non-moving violations, the total fines, the total penalties, and the total amount due are to be printed at the end of processing all records. The format for the output report is illustrated below.




Click the following link to get sample download of LogicCoder flowchart files.

Here is another sample program problem in which an algorithm is required that scan through a data file consisting of records in order to determine the largest and the smallest in a selected field. In this case, the program problem is specific as you can determine from the specification given. However, the problem belong to a class of well known or common problem. Therefore, a generalise or generic algorithm would be useful for implementing a solution.

If you were to use LogicCoder to derive a solution to this problem, you could use this single solution to generate the required generic algorithm. In LogicCoder, we call a flowchart that represent a generic algorithm a "Template flowchart". You can use a template flowchart to quickly implement the solution to any problem that belong to the class of problems represented by the generic algorithm.

Problem Specification
A program is to be designed and then coded in BASIC that will produce a wheat production listing. Each input record used in the data file contain the field number from which the wheat is harvested, and the tonnage of wheat produced. The following information should be listed at the end of the report: The total tonnage of wheat produced from all fields, The field number and tonnage of the field that produce the most wheat, The field number and tonnage of the field that produce the least wheat. The input test data is given below.

Problem Flowchart Solution
Program logic to select maximum and minimum




Notice from this program logic design that you are basically selecting the maximum and the minimum values from a set of values. Therefore, the instance of this program algorithm implement the solution of a more general problem, i.e. selection of the maximum and the minimum from a set of values. This gives us the opportunity to create what we call a "GENERIC SOLUTION" for this class of problems. LogicCoder allow you to create generic solutions to class of programming problems by creating a "Template flowchart" from a given instance within that class of problems. You can then use the template flowchart to implement a solution to any problem within the class of problems. You can also create template flowchart base solely on a visual perception in the control logic presented in a flowchart. Therefore, you can have template for class of problems that has similar processing pattern requirement.

More advance versions of LogicCoder allow you to select to generate BASIC programs with the use of standard control structures as opposed to that that uses the traditional line numbering as illustrated here. Many high level programming languages implement these standard control structures with the use of standard control statements such as do-while, while, if, if-then and so on. Never the less, as we have seen, with LogicCoder there is no need to think about these control statements when writing the source code for a program.

Click the following link to download a copy of this flowchart and the C/C++ source code text file.


You are to design a program and then write the source code. The program is to encode the sorted sequence for a set of data values from two pre-sorted lists that are to be merged in-place. In addition, the permutation sequence should encode the order in which values are to be selected from the two list been merged in a stable manner.

A merge or sort algorithm is said to be in-place whenever it does merging or sorting with the use of constant amount of extra memory. In this case, the amount of memory required to implement the algorithm does not depend on the number of records in the input list(s). In addition, a merge algorithm is stable if it always leave sequences of equal data values in the same order at the end of merging. For example, if we have the set of indexed values in the A list and the B list as follows.

Illustration of stable merge



Most information listed on this web page are taken from the following text books
(1) STRUCTURED PROGRAMMING WITH BASIC, Vol. 1, ISBN 0-9544270-1-7; Price $44.00 USD
(2) STRUCTURED PROGRAMMING WITH ANSI C; ISBN 0-9544270-0-9; Price $56.00 USD

Copy right © May 2002
Logic Code Generator Ltd

Tel: +44(0)74596 09126
E-mail: info@

You must not take information from this web page and reuse without the owner's permission!