After studying this tutorial you will now know how to assign a value to a variable or memory location and how you shout to the computer to stop what whatever it is doing at a particular time and start again if you wish.
1. Basic Computer Assignment Operation:
An assignment operation is an operation that causes a computer to store or keep value in it memory. It must specify the destination for the value, which is specified in the instruction. This may be a constant or a value optioned from evaluating an expression.The following are normally used when specifying an assignment operation:
assign … to, store … in …, move … in …, put … in …, copy/save … to/in …, etc.
Instance one:Store Albert Einstein in Name
Put 25 in Age
Copy Age to Height.
Some time the value assigned, is obtained from some arithmetic operation when this happens it called arithmetic assignment. Assignment operation is a destructive operation.
1. Create a memory location, called the memory location
An assignment operation triggers a computer to:
i. Obtain the value of the expression on the right hand side;
ii. Replace the content of the result variable on the left hand side with this value.
iii. End
The explanation is as illustrated below:
What I have explained above is the basic of how computer assign value(s) to a variable(s). The following instances move steps will take us higher.
Instance two:
0. START
1. Go into the memory and map out a location
2. Called the mapped out location Name
3. Go into the memory and map out another a location
4. Called the mapped out location Age
5. Go back into the memory and map out another location
6. Called the location Height
7. Go back into the memory and map out another location
8. Called the location Items
9. END
The above operation only create a memory location inside the memory where to keep/hold any value as specified by the name of the locations. The variables or names of the locations are: Name, Age, Height and Items. When a memory location is created, it is created for a purpose. Perhaps it may be the Name of your dog, the Age, Height and Items it normally stay on or play with that triggered to create those memory space in the instance two above. Who knows if you have created it for your self.
The below operation now put the assignment operation in action. I will now combined what is written above at instance one and introduce some other things that will make the instructions be an assignment operation. In other words it show you how value are assigned to variable (... how value are store or kept in a memory).
Instance Three1. Start
1. Create the following locations; Name, Age, Height and Items
2. Name = Albert Einstein
3. Age = 25
4. Height = 66
5. Items = Laptop, Light
6. END
In the above instance, Albert Einstein, 25, 66 and Laptop, Light were stored (kept or assigned) in the memory locations; Name, Age, Height and Items respectively.
2. Basic Computer Termination Operation:
Computer stops working on the problem only if you tell it to stop. Why? The computer never know when it started how could it now know when to stop. You are the one to tell computer to start or stop working on the specified problem.Therefore a termination operation stops the CPU working on your problem and starts or continues to work on another different problem if there is any, otherwise it will be idle until you shut the computer down. Verbs used to specify a termination operation includes: stop, end, quit etc.
Instance:
PRINT “Albert Einstein”You don’t need a prophet to tell you that the computer will print/display the following:
PRINT “25”
STOP
PRINT 50
END
Albert Einsteinand stop executing or terminate the operation.
25
To print your statement of account from the month of July to the Month of December. The designer of the termination of operation (i.e the programmer) have to specify clearly to the computer where to start/begin (i.e. from the month of July) print and where to stop/end (i.e. to the month of December).
A simple instruction to tell a computer where to start and where to stop is as outlined below for a sorted list/items.
Instance one:1. start
2. check the list of months starting from the first month,
3. IF month = July THEN
4. Print statement of account for the month of July
5. IF month = August THEN
6. Print statement of account for the month of August
7. IF month = September THEN
8. Print statement of account for the month of September
9. IF month = October THEN
10. Print statement of account for the month of October
11. IF month = November THEN
12. Print statement of account for the month of November
13. IF month = December THEN
14. Print statement of account for the month of December
15. END.
There for that start operation begin from one (1) and stop at fifteen (15). However, we are told that the list/items has being sorted (arranged in alphabetical order. To make the work easier and taken the properties of algorithm into consideration, no need of wasting memory and time of executing from one (1) to fifteen (15) above.
If am allowed, I suggest that we make it more concise to save memory space and to minimise the time of execution of the programme. The time of execution is total taken to complete the execution of the programme and the computer will terminate the execution using a termination instruction.
Instance two: my suggestion:1. start
2. Print the statement of account from the month of July to the month of December
3. END
If to execute one computer instruction takes one (1) minute, it therefore means that the total time to execute the first instance is 15 minutes.
If you are the computer obeying these instructions behind the scenes, I know you will bet with your monthly salary that you will not exceed three (3) minutes obeying the instructions on instance two.
Instance:
1. PRINT Name
2. PRINT Age
3. PRINT Items
4. PRINT account balance from the month of February to the month of June
6. Go back to step 1 to print for another person (Start from step 1 for another person)
5. END
Believe that you what will be displayed may be as shown below:
Albert Einstein
25
Laptop, Light
February: $24, 12, 34, 56 ....
March: $11, ....
...
June: $23, 56, 100, 400, ....
And the programme will stop or terminate.
Previous: Basic Computer Assignment Operation | Next: How to Writ a Simple Algorithm Using Pseudo code
SHARE THIS POST WITH YOUR FRIENDS...::
Tweet
0 comments:
Leave a Reply