Pseudo Code Generator

Maximum and Minimum Student Marks Finder

A program that takes the marks of 20 students, calculates the maximum and minimum marks, and outputs these values, while also handling input validation for non-numeric entries.


Empty image or helper icon

Prompt

write a code that takes marks of 20 student and output the max and minimum marks

Answer

Pseudo Code: Finding Maximum and Minimum Marks of Students

Objective

To create a program that accepts the marks of 20 students and outputs the maximum and minimum marks from the entered data.

Inputs and Outputs

  • Input: Marks of 20 students
  • Output: Maximum marks, Minimum marks

Pseudo Code

  1. Initialize Variables

    • Create a list marks to store marks of students.
    • Set max_marks to a very low number (e.g., negative infinity).
    • Set min_marks to a very high number (e.g., positive infinity).
  2. Input Marks

    • For i from 1 to 20 (inclusive):
      • Prompt user for input: "Enter marks for student i:"
      • Read input and convert to integer.
      • Append the input marks to the marks list.
  3. Calculate Maximum and Minimum Marks

    • For each mark in marks:
      • If mark is greater than max_marks:
        • Set max_marks to mark.
      • If mark is less than min_marks:
        • Set min_marks to mark.
  4. Output Results

    • Print "Maximum Marks: " followed by max_marks.
    • Print "Minimum Marks: " followed by min_marks.

Final Notes

  • Ensure that the program handles invalid inputs (non-numeric values) appropriately.
  • Consider adding functionality to display all entered marks if required.

Example Code Snippet (In Python)

# Initialize variables
marks = []
max_marks = float('-inf')
min_marks = float('inf')

# Input marks
for i in range(1, 21):
    mark = input(f"Enter marks for student {i}: ")
    mark = int(mark)  # Ensure the input is an integer
    marks.append(mark)

    # Check for maximum and minimum
    if mark > max_marks:
        max_marks = mark
    if mark < min_marks:
        min_marks = mark

# Output results
print("Maximum Marks:", max_marks)
print("Minimum Marks:", min_marks)

This pseudo code should guide the implementation of a program to determine the highest and lowest marks among 20 students effectively.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

A program that takes the marks of 20 students, calculates the maximum and minimum marks, and outputs these values, while also handling input validation for non-numeric entries.