Computation : Concepts
COMPUTER ARCHITECTURE:
A digital computer consists of(1) A processor (CPU)
(2) One or more input devices
(3) One or more output devices
(4) A memory or storage unit.
The CPU has 3 main sections —
1) Arithmetic logic unit
2) Control unit
3) A few general purpose registers.
The ALU performs Arithmetic Logic operations while control unit decodes the instructions in the program and instruct the various devices associated with the computer to perform various operations. The general purpose registers are used for storing intermediate or partial results temporarily.
The input device is for taking in the Program and Data. The input operation is referred to as Read operation. It is a Floppy Disk or Paper Tape or Card reader.
The output device is for giving out the result. Screen and printer are the widely used types of output devices. The output operation is called as write operation.
A memory is essential in a computer stem for the following purpose :
1. To store large masses or quantity of input data.
2. To store intermediate or partial results.
3. To store final results to be given as output .
4. To store users programmes.
5. To store control programmes and library functions.
The memory unit is made up of a number of locations each of which has a unique address. The total number of location in a memory unit will be the order of 2n where n is an integer and will be equal to the number of lines or bits in what is known as address bus. Address bus is used by the processor to seek any desired location in the memory unit.
Data bus is used to transfer data between processor and input-output devices as well as between processor and memory. The number of lines in the data bus is dependent upon the word-size of the computer.
DIGITAL SYSTEM ALGORITHIMS :
An algorithm is the sequence of logical steps required .to perform a specific task such as solving a problem. Aside from accomplishing its objectives, a good algorithm must have a number of attributes:1. Each step must be deterministic; that is, nothing can be left to chance. The final results cannot depend on who is following the algorithm. In this sense, an algorithm is analogous to a recipe. Two chiefs working independently from a good recipe should end up with dishes that are essentially identical.
2. The process must always end after a finite number of steps. An algorithm cannot be open-ended.
3. The algorithm must be general enough to deal with any contingency.
Figure shows an algorithm for the solution of the simple problem of adding a pair of numbers. Two independent programmers working from this algorithm might develop programs exhibiting somewhat different styles. However, given the same data, their programs should yield identical results.
Step-by-step English descriptions of the sort depicted in the Figure are one way to express an algorithm. They are particularly useful for small problems or for specifying the broad tasks of a large programming effort However, for detailed representation of complicated programs, they rapidly become inadequate. For this reason, more versatile visual alternatives, called .flow charts, have been developed.
FLOW CHARTS :
A flow chart is a visual or graphical representation of an algorithm. The flow chart employ a series of blocks and arrows, each of which represents a particular operations 6r step in the algorithm. The arrows represent the sequence in which the operations are implemented.Figure shows a flow chart for the problem of adding two numbers.Example of Flow Chart
Step 1. Start the calculation
Step 2. Input a value for A
Step 3. Input a value for B
Step 4. Add A to B and call the answer C
Step 5. Output the value for C
Step 6. End the calculation
Symbols used in Flow chart :
Symbol | Name | Function |
Terminal | Represents the beginning or end of a program. | |
Flowlines | Represents the flow of logic. The humps on the horizontal arrow indicate that it passes over and does not connect with the vertical flow lines. | |
Process | Represents calculations or data manipulations. | |
Input/Output | Represents inputs or outputs of data and information. | |
Decision | Represents a comparison, question, or decision that determines alternative paths to be followed. | |
On-page connector | Represents a break in the path of a flow chart that is used to continue flow from one point on a page to another. The connector symbol marks where the flow ends at one spot on a page and where it continues at another spot. | |
Off-page connector | Similar to the on-page connector but represents a break in the path of a flow chart that is used when it is too large to fit on a single page. The connector symbol marks where the algorithm ends on the first page and where it continues on the second. |
Illustration of the use of On-page and Off-page connectors. The dashed lines would not actually be a part of the charts but are used here show to how control is transferred between the connectors.
THE THREE FUNDAMENTAL CONTROL STRUCTURES :
(1) Control Structure > Sequence :
(2) Control Structure > Selection :
(3) Control Structure > Repeation :
STRUCTURE PROGRAMMING :
The structure principle. The static structure (that is. spread out on the page) of the program should correspond in a simple way to the dynamic structure (that is, spread out in time) of the corresponding computation.
Thus, the "jumping around" due to indiscriminate branching and other poor programming habits will be avoided as a natural consequence of the orderly nature of well-conceived computations.
General Structure Programming Rules
In addition to the structure principle, there are several other rules that can be considered as part of the structured programming philosophy. The following are among the most generally agreed upon rules:1. Programs should consist solely of the three fundamental control structures of sequence, selection, and repetition. Computer scientists have proved that any program can be constructed from these basic structures.
2. Each of the structures must have only one entrance and one exit.
3. Unconditional transfers (GO TOs) should be avoided.
4. The structures shguld be clearly identified with comments and visual devices such as indentation, blank lines and blank spaces.
Computer Storage
When we sign off the computer, active file will be destroyed. In order to retain a program for later use, the transfer it to a secondly storage device such a disk or floppy diskettes. The storage and maintenance consists of(1) Upgrading the program in light of experience.
(2) Ensuring that the program is safely stored.
Suggestions and pre-cautions for effective maintenance and storage of software on diskettes :
1. Maintain paper printouts of all finished programs in a file or binder.2. Always maintain at least one backup copy of all diskettes.
3. Handle a diskette gently. Do not bend it or touch its exposed surfaces.
4. Afix a temporary label to each diskette describing its contents. Once the label is attached, only use soft felt-tipped pens to add more information.
5. Once a diskette is complete, cover the write-protect notch with foil tape.
6. Keep the diskette in its protective envelop when not in use.
7. Store diskettes upright in a place that is neither too hot nor too cold.
8. Keep diskettes away from water and contaminants such as smoke and dust.
9. Store diskettes away from magnetic devices such as televisions, tape recorders, electric motors, etc.
10. Remove diskettes from the drives before turning the system off.
11. Never remove a diskette when the red light on the drive is lit.
Computer Storage > Array Storage:
A type of declaration statement is used to allocate storage for an array. Since this is done at compile time, the maximum amount of storage needed must be allocated. In the following example, five numbers at most can be stored under the name X:Notice that five consecutive storage locations are allocated to the variable X. Since the declared type is real, each storage location can hold one real number. There are five array elements in all.
The following storage arrangements show storage for arrays having explicit lower bounds:
Notice that the array A has 11 elements ; B has eight elements; C has five elements. The subscript indicates the relative position in terms of the order of the elements, not the absolute position in the array.
Arithmetic Expression and Arithmetic Operations :
Basic arithmetic operations:
exponentiation | * * |
multiplication | * |
division | / |
addition | + |
subtraction | - |
The symbol for exponentiation(* *) is understood as a whole; there can be no blank space between the asterisks.
Arithmetic Expression > Mode of Arithmetic results:
If arithmetic is performed on integer operands only, the result is integer. If it is performed on a real operands only, the result is real. If the operand types are mixed, the arithmetic is known as mixed mode, and the result will be the more complex of the two operand types, which is the real type. For example:Expression | Result |
18 + 2 | 20 |
18-9.5 | 8.5 |
12 * 2 | 24 |
6.3 * 2.1 | 13.23 |
13/2 | 6 |
(-13)/2.0 | -6.5 |
13.0/2.0 | 6.5 |
9**2 | 81 |
9 * * (0.5) | 3.0 |
In numerical computations for scientific and engineering problems, it is more common to use arithmetic expressions with variables. Numeric literals, constants, and variables may be mixed. The type of the result depends on the types of the operands. An expression can be used in FORTRAN programming wherever a value of the same type can be used. Also, following the rules of algebra, an expression may contain many operations.
Fortran expression | Result type |
3 + 5 * 6-8/5 | integer constant |
3.0-5.6 + 7.3/2.0 | real constant |
J * I *K -L | implicit integer variable |
A3 - BOT * C + DIM | implicit real variable |
A * I + J9-C/6.0 | mixed mode, real result. |
An algebraic expression that does not have parentheses, complicated fractions, or complicated exponents can be written in FORTRAN by using the FORTRAN symbols in place of the algebraic symbols. Note that symbols must always be used for multiplication and exponentiation.
Algebraic expression | FORTRAN expression |
a + bc - d/e+ f | A + B * C - D / E + F |
lwh | L * W * H |
3.14r2 | 3.14 * R **2 |
a/-5 + 7 | A/(-5)+ 7 |
x-2 + y-2 | X * * (-2) + Y * * (-2) |
These expression are parentheses-free except around a unary operation.
Arithmetic Expression > Assignment statement :
The assignment statement is a fundamental statement in most computer languages, including FORTRAN. Although the equal sign (=) is used in the FORTRAN assignment statement, this symbol does not have the same meaning that it does in algebraic expressions. The meaning of the symbol in FORTRAN is like its meaning in mathematical formulas where it indicates that the value computed from the expression on the right of the equal sign should be assigned to the variable name on the left.A = 0.5* B* H means calculate (BH)/2 and assign the result to A. That is, find the area of a triangle by taking half the base times the height.
Assignment statement prescribes actions to be taken. A calculation may be performed. If necessary, the result is converted to the data type of the variable where it is to be stored, and then it is stored. Therefore assignment statements such as the following are meaningful:
X = 6.0
X = X + 5.0 X :
Before : 6.0
After : 11.0
This means retrieve the current value of X, which is 6.0, add 5.0 to it, and store the result back in X, replacing the value 6.0 with the new value, 11.0. In doing this, the computer loses the old value of X, replacing with the new computed value.
The expression on the right side of an assignment statement may be of any appropriate type and may be a literal or constant, another variable that has already been given a value, or a valid FORTRAN expression to be evaluated. The following are examples of valid assignment statements:
Assignment statement | Comment |
BB = 18.0 | Assuming BB is real, it takes the value 10.8. |
C = X | C is given the same value of X. |
T = 'HEADING' | Assuming T is a charactcrvariable.it lakes 'HEADING' as its value. |
X = 0.5* Y* Z | using the value of Y and Z, 0.5 *Y * Z is calculated and the result is stored in X. |
A = A * C - A / B + A | The old value of A is replaced by a value calculated using the old value of A, B, and C. |
Each assignment statement is carried out in three steps :
1. The computer evaluates the expression on the right side of the equal sign.
2. If the result is not of the same type as the variable on the left side, it is converted to the proper type.
3. The computer assigns the resulting value to the variable on the left side. In effect, the value is stored in the memory location assigned to that variable.
When in integer value is assigned to a real variable, it is converted to a real value having a fractional part of 0 before being stored. When a real value is assigned to an integer variable, the fractional part of the value is discarded before the value is stored.
Assignment statement | Calculated value | Value assigned |
M= 16.0/3.0 | 5.333333 | 5 |
K =-19.0/4.0 | -4.75 | -4 |
N = 3 * 5 * 1.1 | 16.5 | 16 |
X = 2/3 | 0 | 0.0 |
A = 4.0 * * (1/2) | 1.0(4.0**0) | 1.0 |
B = 4.0 ** (1.0/2.0) | 2.0(4.0**0.5) | 2.0 |
Arithmetic Expression > Order of Evaluation :
The order of evaluation of operations in arithmetic expressions depends on the precedence of the operations. This order isHighest | () |
** | |
*/ | |
Lowest | +- |
from ur's -- Bellapuri saikumar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
( www.facebook.com/saikumar544) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hi, this is a very interesting article and I have enjoyed reading many of the articles and posts contained on the website, keep up the good work and hope to read some more interesting content in the future. I got a lot of useful and significant information. Thank you so much. 1961 county exempt california license plate
ReplyDelete