Read this section of program code that inputs 0 positive numbers and then outputs the total. Total = Counter = repeat input num total = Total + Num print total Counter = Counter + until counter = 10 This code works, but it is inefficient
Four statement types and four examples are shown below. Draw a line to connect each statement type to the correct example. Statement type
Download 0.75 Mb. Pdf ko'rish
|
1 2
Bog'liqHomework
2 Four statement types and four examples are shown below.
Draw a line to connect each statement type to the correct example. Statement type Example Assignment FOR X 1 TO 10 Iteration READ X Input PRINT X Output X Y + Z [3] 3 A programmer writes a program to store a patient’s temperature every hour for a day. State the data structure that would be most suitable to use and give the reason for your choice. Data structure ................................................................................................................................... Reason .............................................................................................................................................. ......................................................................................................................................................[2] 4 Identify two different selection statements that you can use when writing pseudocode. 1 ........................................................................................................................................................ .......................................................................................................................................................... 2 ........................................................................................................................................................ ......................................................................................................................................................[2] 5 Read this section of program code that: • inputs 10 numbers • checks whether each number is within a specified range • totals the numbers within the range and outside the range 1 InRange = 0 2 OutRange = 1000 3 FOR Count = 1 TO 10 4 5 INPUT Num IF Num > 10 AND Num < 20 THEN InRange = InRange + 1 6 ELSE OutRange = OutRange - 1 7 Count = Count + 1 8 NEXT X 9 PRINT InRange, OutRange (a) There are four errors in this code. Locate these errors and suggest a correction to remove each error. Error 1 ........................................................................................................................................ Correction .................................................................................................................................. ................................................................................................................................................... Error 2 ........................................................................................................................................ Correction .................................................................................................................................. ................................................................................................................................................... Error 3 ........................................................................................................................................ Correction .................................................................................................................................. ................................................................................................................................................... Error 4 ........................................................................................................................................ Correction .................................................................................................................................. ...............................................................................................................................................[4] 6 REPEAT ... UNTIL and WHILE ... DO ... ENDWHILE are two different loop structures you can use when writing pseudocode. Explain, using examples, why you would choose to use each type of loop. Example 1 ......................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... Reason for choice ............................................................................................................................. .......................................................................................................................................................... .......................................................................................................................................................... Example 2 ......................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... Reason for choice ............................................................................................................................. .......................................................................................................................................................... ......................................................................................................................................................[6] Document Outline
Download 0.75 Mb. Do'stlaringiz bilan baham: |
1 2
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling