write an algoritham to print all the numbers 1 to 10
Answers
QUESTION ;
- write an algoritham to print all the numbers 1 to 10.
ANSWER ;
Here is how you could ask a programmable calculator to display numbers. In order to use this method, we first have to define a value that we will increment.
- 0 → X
This makes sure that we have zero in the variable X.
Now, write a statement to add one to this variable, and remember it.
- X + 1 → X
When we use this statement on the home screen, it immediately shows us the new value.
Here is a screen showing how I initialized the variable with zero, then used the second statement to count from 1 to 4. Keep pressing Enter until you get as high as you want to go.
Of course, we could have put this into a program, but I’ll leave that for another time. Leave a comment if you have a calculator that can handle programs, and I’ll give you some ideas in that direction.
In general, though, we’d only use a PRINT (or DISP or similar) statement once to display the variable, then use statements before and after that statement to control what values of that variable were printed.
❤@vishnu❤