Computer Science Semester Exam ( Chapter 10 )
Write down two types of conditional statement and for each one show how you would select someone whose age was either 10 or 20.
IF ... THEN ... ELSE ... ENDIF ... IF Age = 10 THEN PRINT ' Selected ' ENDIF IF Age = 20 THEN PRINT 'Selected' ENDIF CASE ... OF ... OTHERWISE ... ENDCASE ... CASE Age OF 10 : PRINT ' Selected ' 20 : PRINT ' Selected ' OTHERWISE ENDCASE
Write a pseudocode algorithm to check the level of stock, StockLevel, and output ' Reorder ' when the value falls below 10
IF StockLevel < 10 THEN PRINT ' Reorder ' ENDIF
Write down two different statements that can be used for inputs,
1. INPUT 2. READ
Write down two different statements that can be used for output
1. OUTPUT 2. PRINT
What values will be stored in the following variables when the assignment statements below are completed?
Age - 21 Name - Richard Value - 36 Sum - 57 Flag - True
Four flowchart symbols are shown on the left and four descriptions are shown on the right. Draw lines to connect each symbol to the correct description.
Diagram
Write down three different loop structure.
FOR ... TO ... NEXT REPEAT ... UNTIL WHILE ... DO ... ENDWHILE
Explain how you would change your algorithm to reject any negative numbers,
Put the input statement in a repeat until loop that rejects any number less than zero.
Here are three problems. For each one, choose a different loop structure for your pseudocode solution. Input some numbers and calculate their total, an input of -1 stops the process
Total <— 0 INPUT Number WHILE Number <> -1 Total <— Total + Number INPUT Number ENDWHILE Print Total
Here are three problems. For each one, choose a different loop structure for your pseudocode solution. Input some numbers and calculate their total, stop when the total is greater than 20.
Total <— 0 REPEAT INPUT Number Total <— Total + Number UNTIL Total > 20 Print Total
Here are three problems. For each one, choose a different loop structure for your pseudocode solution. Input 10 numbers and print out their total.
Total <—0 FOR Count <— 1 TO 10 INPUT Number Total <— Total + Number Next Count Print Total