1. algorithm - Basic arithmetic operation

Before we write an algorithm for this process (computer program), it is necessary to create a pseudo code.

Understanding the process:

The very process of adding two numbers, a simple mathematical operation X + Y = Z,

where X and Y are variables containing the values that are summed (summands), and Z is a variable into which is stored the result of the addition (summation).

Limitations of the process:

The value of the variables X and Y must belong to the set of real numbers.

The process (computer program) can be executed multiple times at the request of the user by entering

new values of the variables X and Y. For that we need ANSWER variable at which we enter the response value in text form

"Yes" or "No" if the user wants or does not want to start the program again.

Steps in pseudo code:

1. Start

2. Enter (assigne) value of the variable (addend) X

3. Enter (assigne) value of the variable (addend) Y

4. Calculate Z (Z = X + Y)

5. Display result of addition, value of Z on the monitor with the message "The sum of X and Y is:"

6. Ask the question "Do you want to re-start the program <Y / N>?" and set value to the response variable ANSWER

7. If the ANSWER is "Yes," go to Step 1

8. If the ANSWER is "No," go to Step 9

9. End

Now that we write pseudo code cross writing algorithm:

See Algorithm on the left, and compare it with the pseudo code above.You'll notice that as far as the sequence of steps does not vary, but there are differences in the descriptions of steps.Step 1 is defined as the beginning of program2nd and 3th step in the algorithm are represented by the symbol entry in which are listed the names of variables in which are stored values ​​entered from the keyboard, in this case, X and Y. The enumeration is achieved using point between the variable names.Step 4 is represented by the symbol of data processing, where is addition of values ​​of variables X and Y, and store the result in the variable Z.Step 5 is represented by the symbol output, which in this case means that the monitor shows "The sum of X and Y is " and shortly after that the value of the variable Z.Step 6 is a requirement for entering the value of the variable ANSWER, although the question is not enrolled in a graphic element, it is understood that it will be displayed on the monitor.7 and 8 are represented by a graphic element condition (riddle), where is the question of whether the value of the variable ANSWER is equal "No", that user will not re-start the program, and if the condition is met, the program flow continues to flow lines marked as "Yes" or program is ending. If the value of the variable ANSWER equals "No", the program continues with the lines specified by the current "no", or returns to the beginning. Pseudo code, and thus the algorithm are imperfect in many natural things, so it is necessary to re-think and write pseudo code, and then algorithm. First remark - "What if a user enters as the value of X and Y variables something other than permitted, like entering a number that not belongs to the set of real numbers, or rather the possible answers to the question "Do you want to re-start the program <Y / N>?" enter unforeseen response, also how large numbers are allowed to enter? Then in what format will print the result on the screen (1,234,568.789 or 1 234 or 568.789 1,234,568.789 etc.).

What is more important, but it is obvious, it is that the number of steps in the pseudo code may or may not necessarily correspond to the number of graphic elements in the algorithm!

Try to improve algorithm yourself.

In the chapter Mathematics you can look for the code of program which in addition has the remaining three mathematical operations. It is written in the programminglanguage C# at IDE SharpDevelop, It is neccessary to have installed .Net framework 4.0.

"Basic arithmetic operations"

All the best,

Author