QUESTION 2A pseudo code that reads eleven numbers from the user and prints the average of these eleven numbers. Also counts the occurrence of number 6 in the program. //MAIN MODULECREATE AVERAGE_OF_NUMBERS //an object created to give a call to other modulesCREATE object for AVERAGE_OF_NUMBERSCOMPUTE_INITIALIZE_VARIABLESCOMPUTE_CALCULATE_AVERAGECOMPUTE_DISPLAY_AVERAGEEND//INITIALIZATION MODULECREATEINITIALIZE_VARIABLES//create arrayDECLARE and INITIALIZE MEMORY TO ARRAY ELEVEN_NUMBERS[ ] INITIALIZE an integer CLOCK to value 0INITIALIZE an integer SUM to value 0DECLARE a decimal variable AVERAGEINITIALIZE an integer i to value 1END//CALCULATION MODULECREATE CALCULATE_AVERAGEREPEAT READ ELEVEN_NUMBERS[i] //populate arrayIF ELEVEN_NUMBERS[i] equals 6 //check for the occurrence of number 6INCREMENT CLOCK by 1 //counter incremented in case number 6 foundEND IFUNTIL i equals 11 //Auto increments value of i and checks the conditionSET i = 1REPEAT
Set SUM = SUM + ELEVEN_NUMBERS[i]UNTIL i = 11SET AVERAGE = SUM / 11END//OUTPUT MODULECREATE DISPLAY_AVERAGEPRINT AVERAGE //display average of eleven numbersPRINT CLOCK//display multiple occurrence of number 6ENDQUESTION 3A Pseudo Code that reads a positive integer from user and finds the average of all even numbers between 1 and user’s input. //MAIN MODULECREATE AVERAGE_OF_EVEN_NUMBERSCREATE object for AVERAGE_OF_EVEN_NUMBERSCOMPUTE_INITIALIZE_VARIABLESCOMPUTE_READ_MAX_LIMITCOMPUTE_CALCULATE_EVEN_AVERAGECOMPUTE_DISPLAY_EVEN_AVERAGEEND//INITIALIZATION MODULECREATEINITIALIZE_VARIABLESDECLARE a decimal variable AVERAGEINITIALIZE an integer P to value 0INITIALIZE an integer CLOCK to value 0INITIALIZE an integer I to value 1INITIALIZE an integer SUM to value 0END//INPUT MODULECREATE READ_MAX_LIMITPRINT “INPUT A POSITIVE INTEGER”WHILE P<0 //Ensures validation
End of preview
Want to access all the pages? Upload your documents or become a member.
Related Documents
SIT105 Critical Thinking and Problem Solving | Reportlg...
|9
|1576
|285
Introduction to Computer Science - Algorithms for Problem Solvinglg...
|11
|974
|222
Pseudo Code Solutionslg...
|5
|1038
|420
SIT105 Critical Thinking and Problem Solving for IT Assignmentlg...
|4
|541
|179
Critical Thinking and Problem Solving For IT 1 1 SIT105lg...