Write a program in java to store the computer marks of 75 students and find out the position of the highest and lowest marks.
Answers
The given problem is solved using language - Java.
import java.util.Scanner;
public class Brainly{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter marks of 75 students...");
int n=75,i;
int a[]=new int[n];
for(i=0;i<n;i++){
System.out.print("["+(i+1)+"] = ");
a[i]=sc.nextInt();
}
int max=a[0],min=a[0];
for(int x:a){
if(x>max)
x=max;
if(x<min)
min=x;
}
System.out.print("Student(s) who got the highest marks is at position(s): ");
for(i=0;i<n;i++){
if(a[i]==max)
System.out.print(i+1+" ");
}
System.out.print("\nStudent(s) who got the lowest marks is at position(s): ");
for(i=0;i<n;i++){
if(a[i]==min)
System.out.print(i+1+" ");
}
}
}
- Accept the marks of 75 students and store them in array.
- Now calculate the highest and lowest marks from the array.
- Use a loop to transverse through array elements. If the array element is equal to highest or lowest marks, display its index.
![](https://hi-static.z-dn.net/files/d1b/0ef133c81a084b16d100f9e28d14e1e6.png)