Search code examples
c++pseudocode

Pseudocode for a CPP project


I am trying to learn how to pseudocode. Could you please check my work and see if this is the correct way to develop a pseudo-code?

The problem is this:

"Write a program to ask the user for a series of test scores of students. The compute and print the test scores arithmetic mean for each student"

Here is my Pseudo-Code:

  1. prompt user for studentNum

  2. prompt for testNum

  3. start while loop to collect data: while (i < studentNum)

    3.1 ask for studentName

    3.2 set sum to zero

    3.3 start second nested while loop while (j < testNum)

      3.3.1. ask user for the testScore
    
      3.3.2. collect data using sum variable.
    

    3.4 compute average by dividing sum by testNum

    3.5 display data in the format:

    "For " << studentName << "The average test score was: " << average

Thank you


Solution

  • This still looks a little too much like real code to me. There's no point in being too specific, you might as well write real code.

    Instead of while i < studentNum, say repeat studentNum times.

    Instead of output in the format ... << ... <<, say Display output like: For John Doe, average was 75.0.

    Edit: here is full pseudocode that I would write:

    • input n, the number of students
    • input t, the number of tests per student
    • for each student:
      • for each test, input and accumulate
      • divide this student's sum by number of tests
      • output like For John Doe, average was 75.0