Computer Science, asked by fe3571a77c, 2 months ago

Write a program that reads from the user the number of students in the class and their grades in one class, the program must find the largest and the lowest grades with the sequence of students and then find the average grade of the class, see the example below:

Nis the numbers of students in one class

X is the grade for each student in the class

For example

Student #1 = 89

Student # 260

Student it 80|

You must find the largest and the lowest grades with the sequence of the student.

The largest grade is 89 the student's number is 1

The lowest grade is 60 the student's number is 2

The average grade of the class is 76.333​

Answers

Answered by cutiepiecharul
0

Answer:

idk buddy

Explanation:

plz mark me as brainlist

Answered by dreamrob
0

Program in C++

#include<iostream>

using namespace std;

int main()

{

int n;

cout<<"Enter number of students : ";

cin>>n;

int marks[n];

cout<<"Enter Marks of each student (out of 100) : "<<endl;

for(int i = 0 ; i < n ; i++)

{

 cin>>marks[i];

}

double total = 0.0;

int min = marks[0] , max = marks[0] , min_pos , max_pos;

for(int i = 0 ; i < n ; i++)

{

 total = total + marks[i];

 if(marks[i] < min)

 {

  min = marks[i];

  min_pos = i;

 }

 if(marks[i] > max)

 {

  max = marks[i];

  max_pos = i;

 }

}

double avg = total / n;

cout<<"The highest grade is "<<max<<", the student's number is "<<max_pos+1<<endl;

cout<<"The lowest grade is "<<min<<", the student's number is "<<min_pos+1<<endl;

cout<<"The average grade of the class is "<<avg<<endl;

}

Output:

Enter number of students : 10

Enter Marks of each student (out of 100) :

67

89

45

67

34

99

67

45

23

45

The highest grade is 99, the student's number is 6

The lowest grade is 23, the student's number is 9

The average grade of the class is 58.1

Similar questions