Back to the 2026 paper

Module 2: Arrays and Strings

20267m

A student record system stores marks of 50 students in an array. Construct a Java program to calculate the highest, lowest and average marks and analyse the time complexity of the operations.

Worked SolutionAI Assisted

Find highest, lowest and average marks

public class Marks {
    public static void main(String[] args) {
        int[] marks = {72, 85, 61, 90, 77}; // example values
        int max = marks[0], min = marks[0], sum = 0;
        for (int mark : marks) {
            if (mark > max) max = mark;
            if (mark < min) min = mark;
            sum += mark;
        }
        double average = (double) sum / marks.length;
        System.out.println("Highest = " + max);
        System.out.println("Lowest = " + min);
        System.out.println("Average = " + average);
    }
}

Replace the example array with the 50 students' marks. Initializing max and min from the first element avoids assuming marks are non-negative. A single pass calculates all three values: O(n) time and O(1) extra space.

Similar questions

Database Management SystemConsider: * Student(SID, Name, Dept, Age) * Course(CID, CName, Faculty) * Enroll(SID, CID, Marks) 1. Write relational algebra expressions to find: * a) Students enrolled in DBMS * b) Students scoring >80 marks * c) Students not enrolled in any course 2. Write SQL queries: * a) Find highest marks * b) Find average marks department-wise * c) Display students enrolled in more than two courses 3. Translate the following query into tuple relational calculus: * "Find names of students from CSE department." 4. Convert the following relational algebra into SQL: * \pi_{Name}(\sigma_{Marks > 85}(Student \bowtie Enroll))202510mSoftware EngineeringA program accepts marks from 0 to 100. Construct test cases using Boundary Value Analysis and Equivalence Class Testing and compare the resulting test sets.20267mData MiningThe results of an exam are recorded along with some data about the students. The results can be found in the table below : | ID | Cell No. | Language | Passed all Assignments | GPA | Passed Exam | | :---: | :---: | :---: | :---: | :---: | :---: | | 1 | 93333-11101 | Java | No | 3.1 | Yes | | 2 | 93333-11112 | Java | No | 2.0 | No | | 3 | 93333-11102 | C++ | Yes | 3.5 | Yes | | 4 | 93333-11113 | Python | Yes | 2.5 | Yes | | 5 | 93333-11103 | Java | Yes | 3.9 | No | | 6 | 93333-11114 | C++ | No | 2.9 | No | | 7 | 93333-11104 | Java | No | 1.9 | No | | 8 | 93333-11115 | Python | Yes | 3.2 | Yes | In no more than one page of text, describe the design of a K-Nearest Neighbour classifier to predict if a student will fail or pass the exam.202110mDesign & Analysis of AlgorithmsDiscuss the average, worst, and best time complexity of the algorithm. Give suitable examples.20237m
Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.