0% found this document useful (0 votes)
11 views8 pages

C++ Program for Student Marks Analysis

Uploaded by

yashsawang77
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views8 pages

C++ Program for Student Marks Analysis

Uploaded by

yashsawang77
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

/*

* 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;

Common questions

Powered by AI

The program could introduce an additional section that lists students scoring below the average to ensure comprehensive analysis. Furthermore, adding functionality to group scores into bands or ranges could provide insights into score distributions and performance trends .

The program uses a simplistic linear search technique to identify the lowest and highest marks, which is efficient for small datasets but can be optimized using more sophisticated sorting algorithms or utilizing data structures that maintain running minimums and maximums for quicker access in larger datasets .

The program classifies students as 'Pass' if their marks are 40 or above. To provide more detailed performance insights, additional metrics like grades (A, B, C, etc.) based on score ranges or performance relative to the class average could be used .

The primary functionalities of the given C/C++ program are: calculating the average score of the class, identifying the highest and lowest scores, determining the marks scored by most students, and listing students who were absent for the test .

Using a fixed array size (MAX 20) limits the program to handle only 20 students' data, which is not scalable. This approach can lead to inefficiencies if the student count exceeds the predefined size, necessitating either dynamic memory allocation or reallocation to accommodate larger class sizes .

To enhance accuracy, the program could implement a frequency count array that records how often each score appears, facilitating the identification of the most frequently scored marks. Additionally, using a hash map could efficiently track and tally scores, saving processing time .

The program calculates the average score by summing the marks of students who were present (i.e., marks greater than '-1') and dividing this sum by the count of these students. This excludes absent students from the average, impacting the class statistics by ensuring only present students' performance is reflected .

Incorporating a user interface would enhance usability by providing a visual representation of data, allowing easier interaction such as real-time input validation, dynamic updates to statistics, and graphical data interpretation through charts and tables, making it more accessible for students and faculty .

The program lacks specific input validation for roll numbers, which could introduce data integrity issues if invalid or duplicate entries are accepted. Implementing input validation would ensure only valid, unique roll numbers are processed, maintaining reliable data tracking and minimizing errors .

The program considers a student absent if the marks entered are '-1'. This status is represented by 'A' in the results section. Absent students' scores are excluded from the calculation of the average score since their marks do not contribute to the total .

You might also like