Computer Science Assignment Pseudocode

Added on - 23 Mar 2020

  • 9

    Pages

  • 895

    Words

  • 146

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 3 of 9 pages
[CRITICAL THINKING ANDPROBLEM SOLVING]
QUESTION2A pseudo code that reads eleven numbers from the user and prints the average of theseeleven 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_AVERAGEREPEATREAD 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 evennumbers 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
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document