Write a complete program that prompts the user to enter the number of students and each student’s score,
then finally displays the highest score.(in C++)
The answer to this question is as follows:
The code is as follows:
#include <iostream>
using namespace std;
int main() {
int num_students;
cout<<"Enter the number of students:";
cin>>num_students;
int students[num_students];
cout<<"Enter the students score:\n";
for(int i=0;i<num_students;i++)
{
cin>>students[i];
}
int max=students[0];
for(int i=0;i<num_students;i++)
{
if(max<students[i])
{
max=students[i];
}
}
cout<<"The maximum score is:"<<max;
}
The input and output are provided in the screenshot below:
Get Answers For Free
Most questions answered within 1 hours.