Posts

Showing posts with the label Pascal

Algorithm and Flowchart Simple Calculator

Image
Algorithm :  Initialize val1, val2, oprs, result  Input val1  Input val2  Choose operation (oprs) from +, -, x or :  If you choose operation (+), then the result = val1 + val2  If you select operation (-), then result = val1 - val2  If you select operation (x), then result = val1 * val2  If you select operation (:), then result = val1 / val2  Print results And this is the flowchart :

Algorithms and Programming Languages : How to implement algorithm in some programming languages?

Image
Algorithms and Programming Languages : How to implement algorithm in some programming languages? Consider the following example algorithm used to decompress the contents of array X (i) as below: The above algorithm consists of instructions. Although the instructions are written in codes close to computer programming languages, but the computer can not understand and execute those instructions. Computers can only understand if the instruction is written in a language called programming language. Here is given example of some programming languages as implementation of the above algorithm: It appears that the instructions in the Algorithm are intentionally made close to the instructions used in the programming language. So if it has been written the algorithm to solve a problem, then we can easily convert algorithm into form of programming language.