Difference between revisions of "AS Sample Question"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "Figure 1 contains the pseudo-code for a program to output a sequence according to the ‘Fizz Buzz’ counting game. ==Figure 1== OUTPUT "How far to count?" INPUT HowFar W...")
 
 
Line 1: Line 1:
Figure 1 contains the pseudo-code for a program to output a sequence according to the ‘Fizz Buzz’ counting game.
+
Figure 1 contains the pseudo-code for a program to output a sequence according to the ‘Fizz Buzz’ counting game. The pseudo-code below uses modular (MOD) division to return just the remainder of division calculation.
  
 
==Figure 1==
 
==Figure 1==

Latest revision as of 09:14, 21 December 2018

Figure 1 contains the pseudo-code for a program to output a sequence according to the ‘Fizz Buzz’ counting game. The pseudo-code below uses modular (MOD) division to return just the remainder of division calculation.

Figure 1

OUTPUT "How far to count?"
INPUT HowFar
WHILE HowFar < 1
    OUTPUT "Not a valid number, please try again."
    INPUT HowFar
ENDWHILE
FOR MyLoop ← 1 TO HowFar
   IF MyLoop MOD 3 = 0 AND MyLoop MOD 5 = 0 THEN
       OUTPUT "FizzBuzz"
   ELSE
       IF MyLoop MOD 3 = 0
           OUTPUT "Fizz"
       ELSE
           IF MyLoop MOD 5 = 0
               OUTPUT "Buzz"
           ELSE
               OUTPUT MyLoop
           ENDIF
       ENDIF
    ENDIF
ENDFOR

What you need to do

Write a program that implements the pseudo-code as shown in Figure 1.

Test the program by showing the result of entering a value of 18 when prompted by the program.

Test the program by showing the result of entering a value of -1 when prompted by the program.