You are Here: Home

# Can you explain what "for a = 8 to 19 step 4" as pseudocode means in english?

Announcements Posted on
TSR's new app is coming! Sign up here to try it first >> 17-10-2016
1. First two lines of a given pseudocode are:

for a = 8 to 19 step 4
for b = 1 to 3
Im guessing that this means that "a" is in the range of 8 to 19, and "b" is in the range of 1-3, is this correct?If so, what does the "for" mean at the start if both lines? And what does "step 4 mean"?Thanks!
2. "for" indicates that the code should loop, so the code on the next line should run once for each value. eg
Code:
```for b = 1 to 3
print b```
would print 1, 2, and 3.

"step 4" just means step on by 4 rather than 1, so
Code:
```for a = 8 to 19 step 4
print a```
would print 8, 12, 16.
3. (Original post by schoolcoders)
"for" indicates that the code should loop, so the code on the next line should run once for each value. eg
Code:
```for b = 1 to 3
print b```
would print 1, 2, and 3.

"step 4" just means step on by 4 rather than 1, so
Code:
```for a = 8 to 19 step 4
print a```
would print 8, 12, 16.
Thanks. What do you mean by "the code on the next line should run once for each value"? Do you mean that the "for" means that if a code said "for a = 1 to 5", then the for loop would mean that if the next line was "print a", it would print 1, 2, 3, 4, 5, because it would print each value of "a" one time each?
4. (Original post by blobbybill)
Do you mean that the "for" means that if a code said "for a = 1 to 5", then the for loop would mean that if the next line was "print a", it would print 1, 2, 3, 4, 5, because it would print each value of "a" one time each?
Yes, that's exactly how it works.

## Register

Thanks for posting! You just need to create an account in order to submit the post
1. this can't be left blank
2. this can't be left blank
3. this can't be left blank

6 characters or longer with both numbers and letters is safer

4. this can't be left empty
1. Oops, you need to agree to our Ts&Cs to register

Updated: September 25, 2016
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Today on TSR

### How does exam reform affect you?

From GCSE to A level, it's all changing

Poll
Useful resources