/*
* Assignment No. A2
* Write C/C++ program to store marks scored for first test of subject 'Data Structures and Algorithms' for N
students.
* Compute
* I. The average score of class
* II. Highest score and lowest score of class
* III. Marks scored by most of the students
* IV. List of students who were absent for the test
*/
#include<iostream>
#define MAX 20
using namespace std;
int main()
int stud_roll[MAX], stud_marks[MAX];
char status[MAX];
int n, cnt=0;
float avg, total=0;
cout<<"\nEnter number of students in class :: ";
cin>>n;
for(int i=0;i<n;i++)
cout<<"\nEnter roll number :: ";
cin>>stud_roll[i];
cout<<"\nEnter marks of DSA for roll number "<<stud_roll[i]<<". Please enter '-1' for absent student ::
";
cin>>stud_marks[i];
if(stud_marks[i]>=40)
status[i]= 'P';
else if(stud_marks[i]<40 && stud_marks[i]>=0)
status[i] = 'F';
else
status[i] = 'A';
//Display result
cout<<"\n\n\t\t ***** RESULT ***** \n";
cout<<"\nThe DSA marks data. Marks 40 and above is pass. The marks '-1' shows student is absent :: \n";
cout<<"\nRoll No. \t Marks \t\t Status";
for(int i=0; i<n; i++)
cout<<"\n"<<stud_roll[i]<<" \t\t "<<stud_marks[i]<<" \t\t "<<status[i];
}
//Average Score of Class
cout<<"\n\n1. Average score of class :: ";
for(int i=0;i<n;i++)
if(stud_marks[i]>-1)
total += stud_marks[i];
cnt++;
avg = total/cnt;
cout<<avg;
int min, max1;
max1 = stud_marks[0];
for(int i=0;i<n;i++)
{
if(stud_marks[i]>-1)
min = stud_marks[i];
break;
// Minimum Marks
for(int i=0;i<n;i++)
if(stud_marks[i]<min && stud_marks[i]>-1)
min=stud_marks[i];
}
//Maximum Marks
for(int i=0;i<n;i++)
if(stud_marks[i]>max1)
max1=stud_marks[i];
cout<<"\n\n2. Highest Score :: "<<max1<<"\t\tLowest Score :: "<<min;
//Marks scored by most students
cout<<"\n\n\n3. The DSA marks scored by most student data. \n List of student who scored above average
marks :: \n";
cout<<"\n\nRoll No. \t Marks ";
for(int i=0;i<n;i++)
if(stud_marks[i]>=avg)
cout<<"\n"<<stud_roll[i]<<" \t\t "<<stud_marks[i];
// List Absent Students
cnt = 0;
cout<<"\n\n4. Roll numbers of Absent Students :: ";
for(int i=0;i<n;i++)
if(stud_marks[i]<=-1)
cout<<"\t"<<stud_roll[i];
cnt++;
if(cnt==0)
cout<<"No students were absent for test";
return 0;