Quantcast
Program coding

Custom Search
 
  
 
PROGRAM CODING

It is important to remember program coding is not the first step of programming. Too often we have a tendency to start coding too soon. As we discussed earlier, there is a great deal of planning and preparation to be done prior to sitting down to code the computer instructions to solve a problem. For the example amortization problem (fig. 1-5), we have analyzed the specifications in terms of (1) the output desired; (2) the operations and procedures required to produce the output; and (3) the input data needed. In conjunction with this analysis, we have developed a programming flowchart which outlines the procedures for taking the input data and processing it into usable output. You are now ready to code the instructions that will control the computer during processing. This requires that you know a programming language.

Before getting into the specific programming language called BASIC, it may be helpful to have a greater understanding of programming languages in general.

All programming languages are composed of instructions that enable the computer to process a particular application, or perform a particular function.

Instructions

The instruction is the fundamental element in program preparation. Like a sentence, an instruction consists of a subject and a predicate. However, the subject is usually not specifically mentioned; rather it is some implied part of the computer system directed to execute the command that is given. For example, the chief tells a sailor to "dump the trash." The sailor will interpret this instruction correctly even though the subject "you" is omitted. Similarly, if the computer is told to, "ADD 1234," the control unit may interpret this to mean that the arithmetic-logic unit is to add the contents of address 1234 to the contents of the accumulator.

In addition to an implied subject, every computer instruction has an ex-plicit predicate consisting of at least two parts. The first part is referred to as the command, or operation; it answers the question "what?. " It tells the

PROBLEM DEFINITION MORTGAGE AMORTIZATION—This program is to determine the monthly amount of interest (A) and amount applied to the principal (P) of the mortgage giving the balance (B) at the end of a thirty-six month period.

INPUT: The monthly payment is to be entered as variable D, the beginning balance of the mortgage is to be entered as variable B, and the annual interest rate is to be entered as variable I. This input is to be entered into the system via the terminal.

OUTPUT: The end result is to be a listing displaying the amount applied to principal and interest and the current loan balance each month, with one final entry showing the final payment on the mortgage.

 

Figure 1-5.—Problem Definition and Programming Flowchart. 

computer what operation it is to perform; i.e., read, print, inpit. Each machine has a limited number of built-in operations that it is capable of executing. An operation code is used to communicate the programmer’s intent to the computer.

The second specific part of the predicate, known as the operand names the object of the operation. In general, the operand answers the question "where?." Operands may indicate the following:

1. The location where data to be processed is found.

2. The location where the result of processing is to be stored.

3. The location where the next instruction to be executed is found. (When

this type of operand is not specified, the instructions are executed in sequence.) The number of operands and the structure or format of the instructions vary from one computer to another. However, the operation always comes first in the instruction and is followed by the operand(s). The programmer must prepare instructions according to the format required by the language and the computer to be used.



   


Privacy Statement - Copyright Information. - Contact Us

comments powered by Disqus

Integrated Publishing, Inc.
9438 US Hwy 19N #311 Port Richey, FL 34668

Phone For Parts Inquiries: (727) 755-3260
Google +