The Student Room Group

Ocr computer science gcse

Help needed with programming pleaseeee
Can you be a bit more specific?
Reply 2
Original post by nat5dawg
Can you be a bit more specific?


Like algorithms pseudo code and stuff like that and loops and basically how to concept a program
Original post by IsMo987
Like algorithms pseudo code and stuff like that and loops and basically how to concept a program

That's still a bit vague :/

Could you find a question (maybe from a past paper or something) which you are unsure how to do? It will be much easier for me to help you if I can see exactly what it is you're stuck at.
Reply 4
Original post by nat5dawg
That's still a bit vague :/

Could you find a question (maybe from a past paper or something) which you are unsure how to do? It will be much easier for me to help you if I can see exactly what it is you're stuck at.


Should I send you the question via email
bump
Original post by IsMo987
Should I send you the question via email


Preferably if you could attach it as a screenshot here, or send a link to the past paper itself. Just this way, other people can see this if they also perhaps need help.
Reply 7
Original post by IsMo987
Like algorithms pseudo code and stuff like that and loops and basically how to concept a program


22ED349C-29E5-43E6-AE01-5D80FEFBFDBE.jpg.jpeg hey this is an example
Reply 8
Hey here’s the link as the photo isn’t clear sorry the question is 7
https://www.ocr.org.uk/Images/469791-question-paper-unit-a451-01-computer-systems-and-programming.pdf
Hi,

Here is my solution to that in pseudocode. (This is the style we use in Scotland for Nat5s Highers etc., may be different for GCSE but the basics should be the same)

DECLARE storedNumber INITIALLY 6 (they didnt say a random number, just a number)
DECLARE counter INITIALLY 0

REPEAT
counter += 1
RECEIVE userGuess (INTEGER) FROM KEYBOARD
IF userGuess < storedNumber THEN
SEND "higher" TO DISPLAY
ELSEIF userGuess > storedNumber THEN
SEND "lower" TO DISPLAY
END IF
UNTIL userGuess = storedNumber OR counter = 10

IF userGuess = storedNumber THEN
SEND "congratulations" TO DISPLAY
END IF


Evaluating this, I see a fixed loop (ie FOR counter FROM 0 TO 9 ..... END FOR) could maybe have been used, but the conditional loop (the one in the example) works fine.

Any questions on how I came to that solution just ask away.

(Also if this is wrong, please quote me and I'll change it accordingly)
(edited 5 years ago)
Reply 10
Original post by nat5dawg
Hi,

Here is my solution to that in pseudocode. (This is the style we use in Scotland for Nat5s Highers etc., may be different for GCSE but the basics should be the same)

DECLARE storedNumber INITIALLY 6 (they didnt say a random number, just a number)
DECLARE counter INITIALLY 0

REPEAT
counter += 1
RECEIVE userGuess (INTEGER) FROM KEYBOARD
IF userGuess < storedNumber THEN
SEND "higher" TO DISPLAY
ELSEIF userGuess > storedNumber THEN
SEND "lower" TO DISPLAY
END IF
UNTIL userGuess = storedNumber OR counter = 10

SEND "congratulations" TO DISPLAY


Evaluating this, I see a fixed loop (ie FOR counter FROM 0 TO 9 ..... END FOR) could maybe have been used, but the conditional loop (the one in the example) works fine.

Any questions on how I came to that solution just ask away.

(Also if this is wrong, please quote me and I'll change it accordingly)

Thank you sooo much its really helpful How would I write this for fixed loop
Original post by IsMo987
Thank you sooo much its really helpful How would I write this for fixed loop


No problem!

By the way, I noticed you seen my reply before I could edit it - please note I made a small change here:
.......
IF userGuess = storedNumber THEN
SEND "congratulations" TO DISPLAY
END IF
......


Basically the way I had it initially would always display the 'congrats' message, even if their guess wasn't correct. The pseudocode above is how it should look.

Now, as for how to do this with a fixed loop - I, again, did not think about it deeply enough lol. I actually believe there is no simple/efficient way to do it with a fixed loop, so the conditional actually looks like the only viable option in this case.

Quick Reply

Latest

Trending

Trending